Created
November 30, 2022 14:01
-
-
Save rapidcow/a5845fb6efea909220e537177d7c7f5a to your computer and use it in GitHub Desktop.
graphs of the famous sinc function and its "other side" (im sorry i can never rember those quirky option names in pgfplots- π)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage[a4paper]{geometry} | |
\usepackage{amsmath} | |
\usepackage{pgfplots} | |
\pgfplotsset{compat=1.18} | |
\usetikzlibrary{calc} | |
\begin{document} | |
\begin{center} | |
\begin{tikzpicture} | |
% Stretch factors (xscale and yscale seem to distort line width) | |
\pgfmathsetmacro\xs{0.25} | |
\pgfmathsetmacro\ys{1.5} | |
\def\ticklen{0.35ex} | |
\draw[semithick,->] (-6.5*pi*\xs,0) -- (6.5*pi*\xs,0) node[above] {$x$}; | |
\draw[semithick,->] (0,-0.25*\ys) -- (0,1.25*\ys) node[left] {$y$}; | |
\foreach \x in {2,3,...,6,-2,-3,...,-6} { | |
\draw (\x*pi*\xs,\ticklen) -- (\x*pi*\xs,-\ticklen) | |
node[below, font=\scriptsize] {\mathstrut$\x\pi$}; | |
} | |
\foreach \x/\xx in {-pi/$-\pi$, pi/$\pi$} { | |
\draw (\x*\xs,\ticklen) -- (\x*\xs,-\ticklen) | |
node[below, font=\scriptsize] {\mathstrut\xx}; | |
} | |
\foreach \y in {1,0.5} { | |
\draw (\ticklen,\y*\ys) -- (-\ticklen,\y*\ys) | |
node[left, font=\scriptsize] {\mathstrut$\y$}; | |
} | |
% https://tex.stackexchange.com/a/128166 | |
\begin{axis}[ | |
anchor=origin, % Align the origins | |
x=1cm, y=1cm, % Set the same unit vectors | |
hide axis, | |
] | |
\addplot [semithick,red,samples=1000,domain=-6.3*pi*\xs:6.3*pi*\xs] | |
{\ys*sin(deg(x/\xs))/(x/\xs)}; | |
\end{axis} | |
\node[red,right] at (pi*\xs,0.5*\ys) {$y = \dfrac{\sin(x)}{x}$}; | |
\end{tikzpicture} | |
\end{center} | |
\begin{center} | |
\begin{tikzpicture} | |
\pgfmathsetmacro\xs{30} | |
\pgfmathsetmacro\ys{20} | |
\def\ticklen{0.35ex} | |
\draw[semithick,->] ({-1/(1.75*pi)*\xs},0) -- ({1/(1.75*pi)*\xs},0) | |
node[above] (x) {$x$}; | |
\draw[semithick,->] (0,-0.1*\ys) -- (0,0.1*\ys) | |
node[left] (y) {$y$}; | |
\begin{axis}[ | |
anchor=origin, % Align the origins | |
x=1cm, y=1cm, % Set the same unit vectors | |
hide axis, | |
] | |
\foreach \lo/\hi/\sam in {{-1/(1.75*pi)*\xs}/{-1/(4*pi)*\xs}/500, | |
{1/(4*pi)*\xs}/{1/(1.75*pi)*\xs}/500, | |
{-1/(4*pi)*\xs}/0.0001/5000, | |
0.0001/{1/(4*pi)*\xs}/5000} | |
{ | |
\addplot [semithick,smooth,blue,samples=\sam,domain=\lo:\hi] | |
{\ys*(x/\xs)*sin(deg(1/x*\xs))}; | |
} | |
\end{axis} | |
\pgfmathsetmacro\M{1/(2*pi)} | |
\draw[dashed] (-\M*\xs,-\M*\ys) -- (+\M*\xs,+\M*\ys); | |
\draw[dashed] (-\M*\xs,+\M*\ys) -- (+\M*\xs,-\M*\ys); | |
\foreach \x/\xsi/\xsj in {-2/-1/2\pi,-3/-1/3\pi,-4/-1/4\pi,-5/-1/5\pi, | |
2/1/2\pi,3/1/3\pi,4/1/4\pi,5/1/5\pi} { | |
\path ({1/pi/(\x)*\xs},\ticklen) -- ({1/pi/(\x)*\xs},-\ticklen) | |
node[below, font=\scriptsize, fill=white, | |
inner sep=0.5*\ticklen] {\mathstrut$\frac\xsi\xsj$}; | |
} | |
\node[blue,right] at (0.0075*\xs,0.11*\ys) | |
{$y = x \sin\biggl(\dfrac{1}{x}\biggr)$}; | |
\end{tikzpicture} | |
\end{center} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment