Day 09

Tuesday, Feb 28, 2017


Ch 3 Fourier Series


Can we find a mixture of the following solutions of our PDE to match any given boundary function around the outside?

disk_eigenfunctions.png 2017_02_28/20170228_134232.jpg


day_09_slides.jpg-000.jpg day_09_slides.jpg-001.jpg

Periodic extension of f on [-L,L).

Convergence? Let's explore a little ... we can compute the integrals for the Fourier coefficients numerically:

%matplotlib inline
import matplotlib.pyplot as pl
from numpy import *
from scipy.integrate import quadrature

def draw(f,filenameprefix,M):
         def ai(x,n): return f(x)*cos(n*pi*x/L)
         def bi(x,n): return f(x)*sin(n*pi*x/L)
         a0 =            (quadrature(ai,-L,0,args=(0))[0] + quadrature(ai,0,L,args=(0))[0])/2  # (Splitting it in two to make quadrature
         def a(n): return quadrature(ai,-L,0,args=(n))[0] + quadrature(ai,0,L,args=(n))[0]     #  easier if there is a discontinuity at 0)
         def b(n): return quadrature(bi,-L,0,args=(n))[0] + quadrature(bi,0,L,args=(n))[0]
         def ff(x,m): return a0*ones_like(x) + array([a(n)*cos(n*pi*x/L) + b(n)*sin(n*pi*x/L) for n in range(1,m+1)]).sum(axis=0)
         x = linspace(-L,L,600)
         fx = f(x)
         for m in range(0,M+1):
             pl.subplot(1,2,1); pl.plot(x,fx,'b',alpha=0.5,lw=3)
             foux = ff(x,m)
             pl.subplot(1,2,1); pl.plot(x,foux   ,'k'); pl.title('f itself (blue) and Fourier partial sum to '+str(m))
             pl.subplot(1,2,2); pl.plot(x,foux-fx,'r'); pl.title('Error with terms up to n='+str(m)+' included')

A perfectly nice example

This function has continous periodic extension:

f(x) = esin((nπx)/(L))

and the Fourier series converges to f rapidly.

I am computing the integrals for the Fourier coefficients numerically.

L = 1
def f(x): return exp(sin(pi*x/L))
expsin_1.png expsin_2.png expsin_3.png expsin_4.png expsin_5.png

An example with a jump discontinuity

def f(x):
         fx = x+L
         fx[x>0] -= 2*L
         return fx


We see overshooting. Nevertheless, the Fourier series converges to f(x) at every x except the point of discontinuity:

sawtooth001.png sawtooth005.png sawtooth009.png sawtooth013.png sawtooth017.png sawtooth021.png day_09_slides.jpg-005.jpg

An example where we can easily compute the Fourier coefficients exactly


Code: Computing Fourier partial sums in some examples

The periodic extension of this function has a jump disconinuity at ±10, ±30, ±50... and at ...,  − 23,  − 3, 23, 43, ....

We see the Gibbs overshoot:

student-suggested_example1.png student-suggested_example11.png student-suggested_example21.png student-suggested_example31.png student-suggested_example41.png student-suggested_example51.png student-suggested_example101.png student-suggested_example151.png