Wolfram Language

Partial Differential Equations

Solve a Basic SturmLiouville Problem

Solve an eigenvalue problem with Dirichlet conditions.

In[1]:=
Click for copyable input
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]:=
Click for copyable input
eigfuns = Table[y[x] /. sol[[1]] //. {\[FormalN] -> i, \[Lambda] -> \[FormalN]^2} /. {C[ 1] -> 1}, {i, 5}]
Out[2]=

Plot the eigenfunctions.

In[3]:=
Click for copyable input
Plot[Evaluate[eigfuns], {x, 0, Pi}]
Out[3]=

Solve an eigenvalue problem with Neumann conditions.

In[4]:=
Click for copyable input
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]:=
Click for copyable input
eigfuns = Table[y[x] /. sol[[1]] //. {\[FormalN] -> i, \[Lambda] -> \[FormalN]^2} /. {C[ 1] -> 1}, {i, 5}]
Out[5]=

Plot the eigenfunctions.

In[6]:=
Click for copyable input
Plot[Evaluate[eigfuns], {x, 0, Pi}]
Out[6]=

Related Examples

de es fr ja ko pt-br ru zh