Illustrating the phase-amplitude identity

Plot[3*Cos[θ]+5*Sin[θ],{θ,-4Pi,4Pi}]

Plot[12*Cos[θ]+5*Sin[θ],{θ,-4Pi,4Pi}]

a=12;
b=5;
c=Sqrt[a^2+b^2];
δ=ArcTan[b/a];
Plot[a*Cos[θ]+b*Sin[θ],{θ,-4Pi,4Pi}]
Plot[c*Cos[θ-δ],{θ,-4Pi,4Pi}]

Frequency spectrum example 1

We first repeat the set-up from yesterday's example of computing the Fourier series for the exponential function.

f[x_]=Exp[x]

Integrate[f[x]Cos[n x],{x,-Pi,Pi}]/Pi

Simplify[%,Assumptions->n∈Integers]

a[n_]=%

Integrate[f[x]Sin[n x],{x,-Pi,Pi}]/Pi

Simplify[%,Assumptions->n∈Integers]

b[n_]=%

a[1]

N[%]

b[1]

N[%]

a[0]=Sinh[Pi]/Pi

To get the frequency spectrum, we compute

c[n_]=Sqrt[a[n]^2+b[n]^2]

To be complete, we define c[0]:

c[0]=Abs[a[0]]

Looking at a list of the first ten values:

Table[c[n],{n,0,10}]

N[%]

And a plot of these:

ListPlot[Table[{n,c[n]},{n,0,10}],PlotRange->{0,10},PlotStyle->AbsolutePointSize[5]]

Frequency spectrum example 2

Clear[f,a,b,c]

f[x_]=x(1-x^2)

Integrate[f[x]Cos[n x],{x,-Pi,Pi}]/Pi

Simplify[%,Assumptions->n∈Integers]

a[n_]=%

Integrate[f[x]Sin[n x],{x,-Pi,Pi}]/Pi

Simplify[%,Assumptions->n∈Integers]

b[n_]=%

a[0]=2*a[0]

To get the frequency spectrum, we compute

c[n_]=Sqrt[a[n]^2+b[n]^2]

To be complete, we define c[0]:

c[0]=Abs[a[0]]

Looking at a list of the first ten values:

Table[c[n],{n,0,10}]

N[%]

And a plot of these:

ListPlot[Table[{n,c[n]},{n,0,10}],PlotRange->{-0.5,10},PlotStyle->AbsolutePointSize[5]]

Plot[{f[x],a[2]*Cos[2x]+b[2]*Sin[2x]},{x,-Pi,Pi}]