\documentclass[varwidth=13.1cm, border={0.0cm 0.0cm 0.0cm 0.0cm}]{standalone} \usepackage{tikz} \usepackage[dvipsnames]{xcolor} \usepackage{pgfplots} \pgfplotsset{compat=1.18} \usepackage{amsmath} \newcommand{\Frac}[1]{\operatorname{frac}#1} \begin{document} \begin{tikzpicture}[scale=0.5] \draw[very thin,color=gray] (-pi * 3,-pi * 1.2) grid (pi * 3, pi * 1.2); \draw[->] (-3.2*pi,0) -- (3.2*pi,0) node[right] {$x$}; \draw[->] (0,-pi * 1.4) -- (0,pi * 1.5) node[above] {$f(x)$}; \foreach \i in {-2, 0, 2}{ \pgfmathsetmacro{\start}{(\i - 1) * pi} \pgfmathsetmacro{\end} {(\i + 1) * pi} \draw[thick, color=NavyBlue] plot [domain=\start:\end, samples=100] (\x, {((\x * 1/(2 * pi) + 0.5) - floor(\x * 1/(2 * pi) + 0.5)) * 2 * pi - pi} ); } \draw[thick, color=OrangeRed] plot [domain=-pi * 3:pi * 3, samples=1000] (\x, {sin((((\x * 1/(2 * pi) + 0.5) - floor(\x * 1/(2 * pi) + 0.5)) * 2 * pi - pi) r)} ); \node[NavyBlue] at (0, -5.4) {$f(x) = \Frac(x \cdot \frac{1}{2\pi}+0.5) \cdot 2\pi - \pi $}; \node[OrangeRed] at (0, -6.6) {$f(x) = \sin( \Frac(x \cdot \frac{1}{2\pi}+0.5) \cdot 2\pi - \pi ) $}; \draw [dashed, color=ForestGreen] (-2 * pi,-3.8) -- (-2 * pi,3.8) node[above] {$x=-2\pi$}; \draw [dashed, color=Brown] (2 * pi,-3.8) -- (2 * pi,3.8) node[above] {$x=2\pi$}; \draw [dashed, color=Fuchsia] (-3.0,pi) -- (3.0,pi) ; \draw [color=Fuchsia] (0, pi + 0.5) node {$y=\pi$}; \draw [dashed, color=Peach] (-3.0,-pi) -- (3.0,-pi) ; \draw [color=Peach] (0, -pi + 0.5) node {$y=-\pi$}; \end{tikzpicture} \end{document}