Sturm--Liouville Problems

Brown University, Applied Mathematics


Return to computing page
Return to MuPAD tutorial page for the first course
Return to MuPAD tutorial page for the second course
Return to the main page (APMA0340)

Sturm--Liouville Problems

Consider a periodic function \( f(x) \) with period \( T = e\ell \); for instance, let \( f(x) =x \). We can expand this function into Fourier series:
\[ f(x) \sim \frac{a_0}{2} + \sum_{n\ge 1} \left( a_n \cos \frac{n\pi x}{\ell} + b_n \sin \frac{n\pi x}{\ell} \right) ,\]

where the coefficients are defined according to Euler--Fourier formulas

\[ a_n = \frac{1}{2\ell} \,\int_{-\ell}^{\ell} f(x)\, \cos \frac{n\pi x}{\ell} \, {|text d}x , \qquad n=0,1,2,\ldots , \] \[ b_n = \frac{1}{2\ell} \,\int_{-\ell}^{\ell} f(x)\, \sin \frac{n\pi x}{\ell} \, {|text d}x , \qquad n=0,1,2,\ldots , \]

Let us choose \( f(x) = x^2 \) on the interval [0,2].

f := x^2:
f2 := (x+2)^2:
l := 1:
a_0 := 1/l*(int(f2,x=-1..0)+int(f,x=0..1)):
cs := cos(k*PI*x/l):
sn := sin(k*PI*x/l):
a_k := simplify(1/l*(int(f2*cs,x=-1..0)+int(f*cs,x=0..1))):
b_k := simplify(1/l*(int(f2*sn,x=-1..0)+int(f*sn,x=0..1))):
Fourier := a_0/2 + sum(a_k*cs + b_k*sn,k=1..n):
a := 100:
Cesaro := sum(Fourier,n=1..a)/a:
plot(Cesaro,x=-2..2)

Another approach:

f:=x->x;
L:=2;
a0:=int(f(x),x=-L..L)/(2*L)
assume(n,Type::NonNegInt)
an:=simplify(int(f(x)*cos(n*PI*x/L),x=-L..L)/L)
bn:=simplify(int(f(x)*sin(n*PI*x/L),x=-L..L)/L)
a:=m->subs(an,n=m);
a(0):=a0;
b:=m->subs(bn,n=m);
b(1)

Fourier series with N +1 terms:
S:=N->a(0) + sum(a(n)*cos(n*PI*x/L)+b(n)*sin(n*PI*x/L),n=1..N)
S(4)
plot(f,S(1),S(2),S(3),x=-L..L)
plot(f,S(10),x=-L..L)

Cesaro series:
C:=N->a(0) + (sum(a(n)*(N+1-n)*cos(n*PI*x/L)+b(n)*(N+1-n)*
sin(n*PI*x/L),n=1..N))/(N+1)
plot(f,C(10),x=-L..L)

Step-function on the interval [-1/2, 1/2]:
f:=piecewise([x<=-1/2,0],[x>-1/2 and x<1/2,1],[x>1/2,0])
plot(f,x=-1..1)

Another piecewise continuous function:
f:=piecewise([x<=-1/2,x],[x>-1/2 and x<1/2,x^2],[x>1/2,-x])
plot(f,x=-1..1)

 



Congrats! You now have just opened MuPAD. Click "Next" to continue.

Home

Next >