Created
June 6, 2017 16:18
-
-
Save seungwonpark/b10d86dd27920bba4b33d41e81855c47 to your computer and use it in GitHub Desktop.
Fourier Series of Square Wave
This file contains hidden or 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
% Fourier Series of Square Wave - illustrated and computed by TeX. | |
% Author : Seungwon Park (swpark.me) | |
% convert -delay 10 -loop 0 -density 400 -alpha remove square-wave.pdf square-wave.gif | |
\documentclass[tikz]{standalone} | |
\usepackage{tikz} | |
\usetikzlibrary{calc} | |
\usepackage{amsmath,amssymb} | |
\usepackage{centernot} | |
\begin{document} | |
\foreach \angle in {0,4,...,360}{ | |
\begin{tikzpicture} | |
\draw[white] (-4,-1.6) rectangle (6.5,5); % frame | |
\node at (1.5,3.5) {\fbox{\parbox{6cm}{\centering | |
Fourier Series of Square Wave \\ | |
~ \\ | |
$ \displaystyle f(x) = \frac{4}{\pi} \sum_{2\centernot\mid n}^{\infty} | |
\frac{1}{n}\sin\left(\frac{n\pi x}{L}\right). $ | |
}}}; | |
\draw plot[smooth,samples=100,domain=\angle-360:\angle] (pi/180*\angle-pi/180*\x,{sin(\x)+1/3*sin(3*\x)+1/5*sin(5*\x)+1/7*sin(7*\x)}); | |
\draw (-2,0) circle [radius=1]; | |
\draw (-2,0) -- +(\angle:1); | |
\draw (-2,0) +(\angle:1) circle [radius=1/3]; | |
\draw (-2,0) +($ (\angle:1) + (3*\angle:1/3) $) circle [radius=1/5]; | |
\draw (-2,0) +($ (\angle:1) + (3*\angle:1/3) + (5*\angle:1/5) $) circle [radius=1/7]; | |
\filldraw (-2,0) | |
+(\angle:1) circle (1pt) -- | |
+($ (\angle:1) + (3*\angle:1/3) $) circle (1pt) -- | |
+($ (\angle:1) + (3*\angle:1/3) + (5*\angle:1/5) $) circle (1pt) -- | |
+($ (\angle:1) + (3*\angle:1/3) + (5*\angle:1/5) + (7*\angle:1/7) $) circle (1pt) -- (pi/180*\angle-pi/180*\angle,{sin(\angle)+1/3*sin(3*\angle)+1/5*sin(5*\angle)+1/7*sin(7*\angle)}) circle (1pt); | |
\node at (-2,-1.3) {\footnotesize $ (n=1,3,5,7) $}; | |
\node at (2.8,-1.3) {\footnotesize by Seungwon Park, illustr. \& computed with \LaTeX.}; | |
\end{tikzpicture} | |
} | |
\end{document} |
Nice gif!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://git.io/vHrAL