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]:=

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]:=
f[x_] := E^(-x) x^2 (\[Pi] - x) Sin[4 x]In[3]:=
coeffs = (Table[Integrate[f[x] basis[[i]], {x, 0, Pi}], {i, 6}] //
FullSimplify);Define
as the 
partial sum of the expansion.
In[4]:=
eigexp[x_, n_] := Sum[coeffs[[i]] basis[[i]], {i, n}]In[5]:=
eigexp[x, 3] // NOut[5]=
Compare the function with its eigenfunction expansion for different values of
.
In[6]:=
Table[Plot[{f[x], eigexp[x, i]} // Evaluate, {x, 0, Pi}], {i, 3, 6}]Out[6]=
