Fourier Series

If \(f(x)\) is a piecewise-defined polynomial function on \(-L<x<L\) then the Fourier series

\[f(x) \sim \frac{a_0}{2} + \sum_{n=1}^\infty \left[a_n\cos\left(\frac{n\pi x}{L}\right) + b_n\sin\left(\frac{n\pi x}{L}\right)\right]\]

converges. In addition to computing the coefficients \(a_n,b_n\), it will also compute the partial sums (as a string), plot the partial sums (as a function of \(x\) over \((-L,L)\), for comparison with the plot of \(f(x)\) itself), compute the value of the FS at a point, and similar computations for the cosine series (if \(f(x)\) is even) and the sine series (if \(f(x)\) is odd). Also, it will plot the partial F.S. Cesaro mean sums (a “smoother” partial sum illustrating how the Gibbs phenomenon is mollified).

sage: f1 = lambda t: -1
sage: f2 = lambda t: 2
sage: f = Piecewise([[(0,pi/2),f1],[(pi/2,pi),f2]])
sage: f.fourier_series_cosine_coefficient(5,pi)
-3/5/pi
sage: f.fourier_series_sine_coefficient(2,pi)
-3/pi
sage: f.fourier_series_partial_sum(3,pi)
-3*cos(t)/pi - 3*sin(2*t)/pi + sin(t)/pi + 1/4

Type show(f.plot_fourier_series_partial_sum(15,pi,-5,5)) and show(f.plot_fourier_series_partial_sum_cesaro(15,pi,-5,5)) (and be patient) to view the partial sums.

To plot Fourier partial sums, type:

sage: show(f.plot_fourier_series_partial_sum(15,pi,-5,5))

 

 

Gibbs Phenomenon

 

Cesaro Summation

 

Sage will plot the partial Fourier series Cesaro mean sums (a "smoother" partial sum illustrating how the Gibbs phenomenon is mollified) using the following command:

sage:  show(f.plot_fourier_series_partial_sum_cesaro(15,pi,-5,5))

To plot the original function, type:

sage: f.plot()
sage: g = Piecewise([[(0,pi/2),-1],[(pi/2,pi),x]])
sage:  g.plot()

 

Even and Odd Functions

Differentiation:

Fourier series of periodic functions