Fourier Series and Transform

According to Eqs. (4.1) and (4.2), in the text, we can express a square integrable function f(x) as a sum of trigonometric functions so that



in the interval -L/2 < x < L/2, where

Let’s take an interval of length  L=1 and the triangle function

ClearAll["Global`*"]
L=1;
f[x_]:=Abs[-x]+L/2 
Plot[f[x],{x,-L/2,L/2}]

We numerically calculate the Fourier coefficients (Subscript[a, n]), (Subscript[b, n])

a0:=1/L NIntegrate[f[x],{x,-L/2,L/2}]
a[n_]:=2/L NIntegrate[f[x] Cos[2π n x/L],{x,-L/2,L/2},AccuracyGoal->5]
b[n_]:=2/L NIntegrate[f[x] Sin[2π n x/L],{x,-L/2,L/2}]

and store them in array up to some arbitrary maximum value max=100;

max=100;
a0
acoffs=Table[Chop[a[n]],{n,1,max}]
bcoffs=Table[b[n],{n,1,max}]

Note: because of the symmetry of f(x) in the interval, all (Subscript[b, n]) coefficients vanish and the  (Subscript[a, n]) for n>0, vanish for even n. Thus

Ff[x_,num_]:=a0+Sum[acoffs[[n]] Cos[2 Pi n x/L],{n,1,num}]

Let’s look at a partial series for the partial sum indices num=1,5,11 respectively

Ff[x,1]
Plot[{%,f[x]},{x,-L/2,L/2}]

Ff[x,5]
Plot[{%,f[x]},{x,-L/2,L/2}]

Ff[x,11]
Plot[{%,f[x]},{x,-L/2,L/2}]

Notice that the Fourier sum approximates the function f(x) ever more accurately as we increase the partial sum index.

Problems

For the above interval construct the Fourier sum for the function

f(x)= x.

(1) As you increase the value of the partial sum index, how does the Fourier sum compare with f(x)  in the region near the endpoints of the interval, i.e.  at x=±1/2? 

(2) Construct the quantity 

(Subscript[S, n ])≡(∫_(-L/2)^(L/2))| (Subscript[fourier, n])(x) - f(x) ((|)^2) dx

where (Subscript[fourier, n])(x) is the nth partial Fourier sum for f(x).  Explore the behavior (Subscript[S, n ])as the index n-> ∞.  Compare that with your observations in (1).  The oscillatory behavior  of the Fourier sum, at the endpoints,  persist  as n-> ∞, is called the Gibbs phenomenon.

URL["https://en.wikipedia.org/wiki/Gibbs_phenomenon"]

Fourier Transform

In the limit as L->∞, the Fourier series of a function melds into the Fourier transform pair, Eq. (4.5)


The function h(ξ) is called the Fourier transform of function f(x), and vice-versa.

?FourierTransform

Note: The internal Mathematica function for the Fourier Transform is defined somewhat differently from that given in  Eq. (4.5). See the above entry for the alternative, Mathematica, definition.

Suppose we wish to express the function f(x)=sin[x] Exp[-(x^2)] as a Fourier integral

fun[x_]=Sin[x]Exp[-x^2]
h[u_]=FullSimplify[FourierTransform[Sin[x] Exp[-x^2],x,u]]

To check whether the above integrand does indeed represent f(x) when inserted into the integral we construct the following table

ftable[x_]:=Chop[NIntegrate[ h[u]/Sqrt[2 Pi]Exp[-I u x],{u,-∞,∞},AccuracyGoal->9]]

table1=Table[{x,fun[x]},{x,-2,2,0.1}];
table2=Table[{x,ftable[x]},{x,-2,2,0.1}];

ListPlot[{table1,Re[table2]},PlotMarkers->{{○,Large},{▼,Large}}]

In the figure above the empty circles represent data from the original function f(x), whereas the triangle represent data obtained numerically with its Fourier transform.