Given the Boundary Value Problem

-(
x
e
Y')'=λ
x
e
Y⇔
x
e
Y''+
x
e
Y'+λ
x
e
Y=0
Y''+Y'+λY=0
Y(0)=0,Y(π)=0

a)

Clear["Global`*"]
The eigenvalues of the BVP are
In[]:=
λ[n_]=1/4+n^2;
and the eigenfunctions
In[]:=
Y[x_,n_]=Exp[-1/2*x]*Sin[n*x]
Out[]=
-x/2

Sin[nx]
We check whether the eigenfunctions are orthogonal by calculating the inner product
In[]:=
Integrate[Y[x,1]*Y[x,2],{x,0,Pi}]
Out[]=
1
5
(1+
-π

)
It is not zero, so it is not orthogonal

Normalizing eigenfunctions to the new inner product by weight

In[]:=
Clear["Global`*"]
Given the eigenfunctions
Y
n
(x)
-
x
2
e
sinnx
. Find the weight function
||f
||
m

1
2

1
∫
0
w(x)f(x)d(x)
in which the eigenfunctions are orthogonal .
In[]:=
λ[n_]=1/4+n^2
Out[]=
1
4
+
2
n
In[]:=
Y[x_,n_]=Exp[-1/2*x]*Sin[n*x]
Out[]=
-x/2

Sin[nx]
The norm is now defined
In[]:=
norm[n_]=Sqrt[Integrate[Exp[x]*Y[x,n]^2,{x,0,Pi}]]
Out[]=
π
2
-
Sin[2nπ]
4n
In[]:=
Simplify[%,n∈Integers&&n>0]
Out[]=
π
2
We define the normalized eigenfunctions
X
n
(x)
,
In[]:=
X[x_,n_]=Y[x,n]/norm[n];
We check if the functions
X
n
(x),
X
m
(x)
,
n≠m
, are orthogonal to the inner product with weight
In[]:=
Integrate[Exp[x]*X[x,1]*X[x,2],{x,0,Pi}]
Out[]=
0
So the normalized eigenfunctions are orthogonal to the new inner product with weight
In[]:=
Table[Plot[X[x,n],{x,0,1},PlotStyle{Red,Thick},PlotLabelExpand[X[x,n]]],{n,1,4}]
Out[]=

,
,
,


Expansion to the eigenfunctions in terms of the inner product by weight

We define the function
In[]:=
f[x_]=x*(Pi-x)
Out[]=
(π-x)x
We plot the graph of the function
In[]:=
pic1=Plot[f[x],{x,0,1},PlotStyle->{Thick},PlotRangeAll]
Out[]=
0.2
0.4
0.6
0.8
1.0
0.5
1.0
1.5
2.0
In[]:=
FPS[x_,N_]=FullSimplify
N
∑
n=1
c[n]*X[x,n];
In[]:=
c[n_]=Simplify
1
∫
0
f[x]*X[x,n]x;
Now we define the partial sums

Now we plot the graphs for N=5,15,20

In[]:=
FS1[x_]=FPS[x,5];
In[]:=
pFS1=Plot[FS1[x],{x,0,1},PlotStyle->{Red,Dashed},PlotRangeAll]
Out[]=
0.2
0.4
0.6
0.8
1.0
0.2
0.4
0.6
0.8
In[]:=
FS2[x_]=FPS[x,15];
In[]:=
pFS2=Plot[FS2[x],{x,0,1},PlotStyle->{Magenta,Thick},PlotRangeAll]
Out[]=
0.2
0.4
0.6
0.8
1.0
0.2
0.4
0.6
0.8
In[]:=
FS3[x_]=FPS[x,20];
In[]:=
pFS3=Plot[FS3[x],{x,0,1},PlotStyle->{Black,Dashed,Thick},PlotRangeAll]
Out[]=
0.2
0.4
0.6
0.8
1.0
0.2
0.4
0.6
0.8
In[]:=
Show[pic1,pFS1,pFS2,pFS3]
Out[]=
0.2
0.4
0.6
0.8
1.0
0.5
1.0
1.5
2.0
We note that it does not converge on the function f (x)