Wolfram Language

Differential Eigensystems

Generate an Eigenfunction Expansion

Compute the eigenfunction expansion of the function with respect to the basis provided by a Laplacian operator with Dirichlet boundary conditions on the interval .

In[1]:=
Click for copyable input
basis = DEigensystem[{-Laplacian[u[x], {x}], DirichletCondition[u[x] == 0, True]}, u[x], {x, 0, \[Pi]}, 6, Method -> "Normalize"][[2]]
Out[1]=

Compute the Fourier coefficients for the function .

In[2]:=
Click for copyable input
f[x_] := E^(-x) x^2 (\[Pi] - x) Sin[4 x]
In[3]:=
Click for copyable input
coeffs = (Table[Integrate[f[x] basis[[i]], {x, 0, Pi}], {i, 6}] // FullSimplify);

Define as the ^(th) partial sum of the expansion.

In[4]:=
Click for copyable input
eigexp[x_, n_] := Sum[coeffs[[i]] basis[[i]], {i, n}]
In[5]:=
Click for copyable input
eigexp[x, 3] // N
Out[5]=

Compare the function with its eigenfunction expansion for different values of .

In[6]:=
Click for copyable input
Table[Plot[{f[x], eigexp[x, i]} // Evaluate, {x, 0, Pi}], {i, 3, 6}]
Out[6]=

Related Examples

de es fr ja ko pt-br ru zh