0

I have a function f(x):=\hat{f}(x-\lfloor x\rfloor), where

\hat{f}(x) =     \left\{ \begin{array}{lcl}
  2x   & \mbox{for} & 0\leq x\leq \frac{1}{5} \\
  \frac{1}{2}+\frac{1}{3}(2x-1) & \mbox{for} & \frac{1}{5}\leq x \leq1
            \end{array}\right.

I am going to draw f(x) on the domain [-2,2] in latex via the tikzpicture. My idea is the following: Divide [-2,2] into pieces in order to define one function and draw. But I am pretty sure there is a more clever way to draw it.

\begin{tikzpicture}
  \draw[->] (-2,0) -- (2,0) node[right] {$x$};
  \draw[->] (0,-2) -- (0,2) node[above] {$y$};
  \draw[scale=0.5,domain=0:0.2,smooth,variable=\x,blue] plot ({\x},{2*\x});
 \end{tikzpicture} 
babgen
  • 215
  • 1
    What have you tried so far? And, please note that mathjax is not supported, therefore, please insert the image of your functions. – Raaja_is_at_topanswers.xyz Apr 16 '19 at 09:27
  • I tried the following: \begin{tikzpicture} \draw[->] (-2,0) -- (2,0) node[right] {$x$}; \draw[->] (0,-2) -- (0,2) node[above] {$y$}; \draw[scale=0.5,domain=0:0.2,smooth,variable=\x,blue] plot ({\x},{2*\x}); \end{tikzpicture} But it is not cleaver. – babgen Apr 16 '19 at 09:28
  • Please add a compilable version of your code in your question. – Raaja_is_at_topanswers.xyz Apr 16 '19 at 09:29

0 Answers0