Solve a Basic Sturm–Liouville Problem
Solve an eigenvalue problem with Dirichlet conditions.
In[1]:=

sol = DSolve[{y''[x] + \[Lambda] y[x] == 0, y[0] == 0, y[\[Pi]] == 0},
y[x], x]
Out[1]=

Make a table of the first 5 eigenfunctions.
In[2]:=

eigfuns =
Table[y[x] /.
sol[[1]] //. {\[FormalN] -> i, \[Lambda] -> \[FormalN]^2} /. {C[
1] -> 1}, {i, 5}]
Out[2]=

Plot the eigenfunctions.
In[3]:=

Plot[Evaluate[eigfuns], {x, 0, Pi}]
Out[3]=

Solve an eigenvalue problem with Neumann conditions.
In[4]:=

sol = DSolve[{y''[x] + \[Lambda] y[x] == 0, y'[0] == 0,
y'[\[Pi]] == 0}, y[x], x]
Out[4]=

Make a table of the first 5 eigenfunctions.
In[5]:=

eigfuns =
Table[y[x] /.
sol[[1]] //. {\[FormalN] -> i, \[Lambda] -> \[FormalN]^2} /. {C[
1] -> 1}, {i, 5}]
Out[5]=

Plot the eigenfunctions.
In[6]:=

Plot[Evaluate[eigfuns], {x, 0, Pi}]
Out[6]=
