# Sturm-Liouville Problem

Given the following BVP $$-(e^x Y'(x))'=\lambda e^x Y(x), \quad 0 $$Y(0)=0, Y(\pi)=0$$

I have found that the eigenfunctions are $$Y_n(x)=e^{-\frac{x^2}{2}}\sin{nx}$$

and the eigenvalues are $$\lambda_n=\frac{1}{4}+n^2$$

We check whether the eigenfunctions are orthogonal by calculating the inner product$$\langle f,g\rangle_2=\int_{0}^{1} f(x)g(x) \,dx$$

\[Lambda][n_] = 1/4 + n^2;
Y[x_, n_] = Exp[-1/2*x]*Sin[n*x]
Integrate[Y[x, 1]*Y[x, 2], {x, 0, Pi}]


It is not zero, so it is not orthogonal.

Normalizing eigenfunctions to the new inner product by weight

The norm $$||f||_{\mu}=\int_{0}^{1} \mu(x)f(x)g(x) \,dx$$ is now defined

norm[n_] = Sqrt[Integrate[Exp[x]*Y[x, n]^2, {x, 0, Pi}]]
Simplify[%, n \[Element] Integers && n > 0]
X[x_, n_] = Y[x, n]/norm[n];
Integrate[Exp[x]*X[x, 1]*X[x, 2], {x, 0, Pi}]


So the normalized eigenfunctions are orthogonal to the new inner product with weight

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

We define the function

f[x_]=x*(Pi-x)
pic1=Plot[f[x],{x,0,1},PlotStyle->{Thick},PlotRange->All]



the coefficients of the expansion of g with respect to the normalized eigenfunctions are given

A[n_] = Integrate[Exp[x]*f[x]*X[x, n], {x, 0, Pi}]
Simplify[%, n \[Element] Integers && n > 0]


We define the partial sums

S[x_, N_] := Sum[A[n]*X[x, n], {n, 1, N}];
fig2 = Plot[S[x, 5], {x, 0, 1}, PlotStyle -> {Red, Dashed}]
fig3 = Plot[S[x, 10], {x, 0, 1}, PlotStyle -> {Green}]
fig4 = Plot[S[x, 20], {x, 0, 1}, PlotStyle -> {Black, Dashed}]
Show[fig1, fig2, fig3, fig4]


Is the procedure I am following correct?

You have coded as :

\[Lambda][n_] = 1/4 + n^2;


Y[x_, n_] = Exp[-1/2*x]*Sin[n*x]
Integrate[Y[x, 1]*Y[x, 2], {x, 0, Pi}]

But with the check for orthogonality, the integrand was not multiplied by the weight function. So change the last command to :

Integrate[Exp[x]*Y[x, 1]*Y[x, 2], {x, 0, Pi}]

There seems to be a typo in one of the commands for graphing

Show[fig1, fig2, fig3, fig4]


-- Actually , you mean

Show[pic1, fig2, fig3, fig4]


--

Rest of the calculations are fine.

• This may be more appropriate as a comment than as an answer. Commented Aug 4, 2023 at 15:15