Notebook to demonstrate Fourier transforms.  updated 7/4/2023 

Consider an arbitrary univariate function.  

We already saw that a combination of trignometric functions can be used to represent a vibration on a string. Is it possible that same could be applied for any function ?   It turns out to be true. 

Fourier analysis is named after Joseph Fourier who showed that  functions can be decomposed into oscillatory components. Each component can then be analysed independently of others.  

For example, the vibrations of a car’s suspension can be divided up in frequencies and each frequency analyzed separately.  

Fourier transform is a vast subject which itself is a sub-area of the vast subject of integral transforms.   A simple way to understand the subject is by using complex numbers.  

Given that oscillations in the complex plane are circles, Fourier transform essentially says that I can divide up any function into a summation  of circles in the complex plane.

Complex numbers in Mathematica.  

i = Square-root(-1) 

is represented by    pressing “esc” ii “esc”

xc  = 5 + 8 * I;  yc = 7 + 9* I; 
zc = xc+yc

Recall that a complex number can also be represented by   magnitude and phase by using an exponential.  

Exp[i * T]  =   Cos[T]  + i * Sin[T]

5* Exp[7*I] //N

Exp[(Pi/3) * I]// N

As the angle T in  Exp[ i * T]   goes from 0 to 2 *Pi  (360 deg) we get a circle in the complex place.  

Make a circle in the complex plane.

ω=2*Pi;   (* 1 circle is made for each unit of time *)  
func[t_]:= Exp[I*ω*t];

ReIm[5+I*6]   (* ReIm[C] gives the real and imaginary parts of the complex number C *)

pl = ParametricPlot[ReIm[func[t]],{t,0,1}]; 
Manipulate[Show[{pl,Graphics[{PointSize->Large,Point[ReIm[func[a]]], Line[{{0,0},ReIm[func[a]]}]  } ]}],{a,0,1}]

Add two elements to the function. Notice that each one forms a circle, and second is a circle with a small radius and faster frequency,  but when added they form a spiral.

ω1=2*Pi; 
ω2=2*Pi*8;
func2[t_]:=Exp[I*ω1*t]+(0.5)*Exp[I*ω2*t];

pl2 = ParametricPlot[ReIm[func2[t]],{t,0,1}]; 
Manipulate[Show[{pl2,Graphics[{PointSize->Large,Point[ReIm[func2[a]]], 
Line[{{0,0},ReIm[Exp[I*ω1*a]], ReIm[func2[a]] } ]   }]
  }],{a,0,1}]

Now plot the Im part along the x axis, using the x axis for the parameter t.  We will use the Imaginary part since it is easily plotted along the vertical.

ω1=2*Pi; 
ω2=2*Pi*8;
func2[t_]:=Exp[I*ω1*t]+(0.5)*Exp[I*ω2*t];

pl2 = ParametricPlot[{ReIm[func2[t]],{t,Im[func2[t]]}},{t,0,5},PlotRange->{{-2.,5},{-2.6,2.6}}]; 
Manipulate[Show[{pl2,Graphics[{PointSize->Large,Point[ReIm[func2[a]]],Point[{a,Im[func2[a]]}], 
Line[{{0,0},ReIm[Exp[I*ω1*a]], ReIm[func2[a]] } ]   }]
  }],{a,0,5}]

We need to plot the function first and then have a dot going down the curve. We can do that with DynamicModule and Clock. This is better than using Manipulate because it can be slowed down.

ω1=2*Pi; 
ω2=2*Pi*6;
funcnew[t_]:=Exp[I*ω1*t]+0.*Exp[I*ω2*t]; 
curve = ParametricPlot[{ReIm[funcnew[t]],{t,Im[funcnew[t]]}},{t,0,12},PlotRange->{{-2,12},{-2.,2.}}]

DynamicModule[{t}, DynamicWrapper[Show[curve,Graphics[{PointSize[Large],Red,Point[Dynamic[ReIm[funcnew[t]] ]] }],
Graphics[{PointSize[Large],Blue,Point[Dynamic[{t,Im[funcnew[t]]} ]] }
 ] , Graphics[{Line[{{0,0},Dynamic[ReIm[funcnew[t]] ]}   ] }
 ]
],
t=Clock[{0,12}] 
]
]

Now do a square wave in several steps.

ω01=2*Pi; 
ω02=2*Pi*3;
a01 = 1; 
a02 = 2*a01/(3*Pi);
funcsq[t_]:=a01*Exp[I*ω01*t]+a02*Exp[I*ω02*t]; 
curve = ParametricPlot[{ReIm[funcsq[t]],{t,Im[funcsq[t]]}},{t,0,12},PlotRange->{{-2,12},{-2.,2.}}]

DynamicModule[{t}, DynamicWrapper[Show[curve,Graphics[{PointSize[Large],Red,Point[Dynamic[ReIm[funcsq[t]] ]] }],
Graphics[{PointSize[Large],Blue,Point[Dynamic[{t,Im[funcsq[t]]} ]] }
 ] ],
t=Clock[{0,12}] 
]
]

ω1=Pi; 
ω2=Pi*3;
ω3 = Pi*5; 
ω4=Pi*7;
ω5 = Pi*9;
ω6=Pi*11; 
ω7 = Pi*13; 
a=1; 
a1 = 4*a/Pi; 
a2 = 4*a/(3*Pi);
a3 = 4*a/(5*Pi); 
a4   = 4*a/(7*Pi);
a5 = 4*a/(9Pi); 
a6=4*a/(11Pi); 
(*a7 =4*a/(13Pi); *)
a7 = 0; 
fun1[t_]:=a1*Exp[I*ω1*t]; 
fun2[t_]:=a1*Exp[I*ω1*t]+a2*Exp[I*ω2*t]; 
fun3[t_]:=a1*Exp[I*ω1*t]+a2*Exp[I*ω2*t]+a3*Exp[I*ω3*t]; 
fun4[t_]:=a1*Exp[I*ω1*t]+a2*Exp[I*ω2*t]+a3*Exp[I*ω3*t]+a4*Exp[I*ω4*t]; 
fun5[t_]:= fun4[t]+a5*Exp[I*ω5*t]; 
fun6[t_]:= fun5[t]+a6*Exp[I*ω6*t]; 
fun7[t_] :=  fun6[t]+a7*Exp[I*ω7*t]; 
curve = ParametricPlot[{ReIm[fun7[t]], 
{t,Im[fun7[t]]}},{t,0,12},PlotRange->{{-3,5},{-1.5,1.5}},Frame->True]; 
DynamicModule[{t}, DynamicWrapper[Show[curve,Graphics[{PointSize[Large],Red,Point[Dynamic[ReIm[fun6[t]] ]] }],
Graphics[{PointSize[Large],Blue,Point[Dynamic[{t,Im[fun6[t]]} ]] }
 ] ,
Graphics[Line[{{0,0},Dynamic[ReIm[fun1[t]] ],Dynamic[ReIm[fun2[t]]],Dynamic[ReIm[fun3[t]]], Dynamic[ReIm[fun4[t]]] ,    Dynamic[ReIm[fun5[t]]], Dynamic[ReIm[fun6[t]]] , Dynamic[ReIm[fun7[t]]] }   ] ] 
],
t=Clock[{0,5},60] 
]
]

The Fourier transform breaks up any function into its components.  A very complex function of time or space can be demostrated to be composed of a few large regular oscillations to leading order. 

Gauss:  Fourier transform is like a clothes line for numbers. You tag a number with a sequence number (like a library card) and then you can fetch it using that tag.