Some basic examples of Fourier series, synthesis and series of sines, cosines, rectangle, sawtooth, triangle functions, as well as a 3D figure to breakdown synthesis into the time and frequency domain.
For more Fourier analysis figures, please see the “fourier analysis” tag. These figures are used in Ben Kilminster’s lecture notes for PHY111.
Edit and compile if you like:
% Author: Izaak Neutelings (January 2021)% http://pgfplots.net/tikz/examples/fourier-transform/% https://tex.stackexchange.com/questions/127375/replicate-the-fourier-transform-time-frequency-domains-correspondence-illustrati% https://www.dspguide.com/ch13/4.htm\documentclass[border=3pt,tikz]{standalone}\usepackage{amsmath}\usepackage{tikz}\usepackage{physics}\usepackage[outline]{contour} % glow around text\usepackage{xcolor}\usetikzlibrary{intersections}\usetikzlibrary{decorations.markings}\usetikzlibrary{angles,quotes} % for pic\usetikzlibrary{calc}\usetikzlibrary{3d}\contourlength{1.3pt}\tikzset{>=latex} % for LaTeX arrow head\colorlet{myred}{red!85!black}\colorlet{myblue}{blue!80!black}\colorlet{mycyan}{cyan!80!black}\colorlet{mygreen}{green!70!black}\colorlet{myorange}{orange!90!black!80}\colorlet{mypurple}{red!50!blue!90!black!80}\colorlet{mydarkred}{myred!80!black}\colorlet{mydarkblue}{myblue!80!black}\tikzstyle{xline}=[myblue,thick]\def\tick#1#2{\draw[thick] (#1) ++ (#2:0.1) --++ (#2-180:0.2)}\tikzstyle{myarr}=[myblue!50,-{Latex[length=3,width=2]}]\def\N{90}\begin{document}% SQUARE WAVE\def\xmin{-0.7*\T} % min x axis\def\xmax{6.0} % max x axis\def\ymin{-1.04} % min y axis\def\ymax{1.3} % max y axis\def\A{0.67*\ymax} % amplitude\def\T{(0.35*\xmax)} % period
Click to download: fourier_series.tex • fourier_series.pdf
Open in Overleaf: fourier_series.tex
Dear Prof. Izaak Neutelings,
Your codes are fabulous. I like them. I am a beginner of Tikz. I have a question about the codes for Fourier series.
When you plot the partial sum of the series, you used codes just like this:
plot(\t,{\f{1}+\f{3}+\f{5}+\f{7}+\f{9}+\f{11}},0); %node[above] {$f$};
Can we define a function Sn(N)=f(1)+…+f(N), and use codes like this:
plot(\t,{Sn(x},0); %node[above] {$f$}; ?
Maybe I want to plot Sn(100) . It looks stupid that typing {f(1)+…+f(100}.
Since it is hopeless that you can see this, I am still looking forward to your reply.
Have a good weekend.
Harry Liu