Skip to content

Instantly share code, notes, and snippets.

@kpym
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpym/97855351bef8c5989ba5 to your computer and use it in GitHub Desktop.
Save kpym/97855351bef8c5989ba5 to your computer and use it in GitHub Desktop.
\documentclass[tikz]{standalone}
\usetikzlibrary{math}
\tikzmath{
function sinc(\x) {
if abs(\x) < .001 then { % (|x| < .001) ~ (x = 0)
return 1;
} else {
return sin(\x r)/\x;
};
};
}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (-3.5,-1.5) grid (3.5,1.5);
\begin{scope}[very thick, domain=-pi:pi, samples=100, smooth]
\draw[blue] plot (\x,{sin(5*\x r)});
\draw[red] plot (\x,{sinc(5*\x)});
\end{scope}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment