Given the following problem $$u_{t}-\frac{v}{2}\cdot u_{xx}+\frac{v}{2}\cdot x^2 \cdot u(x)=0 $$ $$u(x,0)=f(x)$$
Where $ f(x)=y_1(x)+0.2y_4(x)+0.01y_6 (x) $
$y_n$ are the Eigenfunctions that defined as $ y_n(x)=\exp\left(\displaystyle{\frac{-x^2}{2}}\right)H_n(x) $
By separation we assume $$u(x,t)=X(x)T(t)$$
$$\frac{T'(t)}{T(t)}=v (\frac{1}{2} \frac{X''(x)}{X(x)}-\frac{x^2}{2})=-\lambda$$
So we have
$$T'(x)=-\lambda v T(x)$$
I have found that the general solution of $T$ is $T(x)=c_1e^{-\lambda v t}$ and for $$\frac{1}{2} \frac{X''(x)}{X(x)}-\frac{x^2}{2}=-\lambda$$ which gives $$-\frac{1}{2}X''(x)+\frac{x^2}{2}X(x)=\lambda X(x)$$
the general solution of $X$ is $ X_n(x)=\exp\left(\displaystyle{\frac{-x^2}{2}}\right)H_n(x) $
So the general solution to our initial problem is $u_n(x,t)=\sum_{n=1}^{\infty}A_n \exp\left(\displaystyle{\frac{-x^2}{2}}\right)H_n(x) c_1e^{-\lambda v t}$
Using the I.C we got $$ u(x,0)=\sum_{n=1}^{\infty}A_n \exp\left(\displaystyle{\frac{-x^2}{2}}\right)H_n(x)=f(x) $$
I found an analytical solution with the following code.
f[x_]:=Exp[-x^2/2] (1+0.2*HermiteH[4,x]+0.01*HermiteH[6,x])
n=10;
A=Table[1/(Sqrt[Pi] 2^m m!) Integrate[f[x] HermiteH[m,x] Exp[x^2/2],{x,0,1}],{m,1,n}];
u[x_,t_]:=Sum[A[[m]] Exp[-m/2 t] Exp[-x^2/2] HermiteH[m-1,x],{m,1,n}]
Plot[{u[x,0],u[x,0.3],u[x,0.7]},{x,-20,20},PlotRange->All,PlotLegends->{"t=0","t=0.3","t=0.7"}]
fig1=Plot3D[u[x,t], {t,0,10},{x,-21,21},PlotRange->All,ColorFunction->"BlueGreenYellow"]
I tried also to write the following code, thus I could compare which one gives me better results but it does not seem to work
(* Define the Eigenfunctions *)
y[n_, x_] := Exp[-x^2/2] HermiteH[n, x]
(* Define the constant *)
v = 1;
(* Find the general solution for T *)
T[x_, t_] := c1 Exp[-v \[Lambda] t]
(* Find the general solution for X *)
X[n_, x_] := y[n, x]
(* Combine to get the general solution for u *)
u[n_, x_, t_] := X[n, x] T[x, t]
(* Define the initial condition *)
f[x_] := y[1, x] + 0.2 y[4, x] + 0.01 y[6, x]
(* Solve for the coefficients *)
An[n_] := (Integrate[f[x] X[n, x], {x, -\[Infinity], \[Infinity]}]) / (Integrate[X[n, x]^2, {x, -\[Infinity], \[Infinity]}])
(* Define the analytical solution *)
u[x_, t_] := Sum[An[n] X[n, x] T[x, t], {n, 1, \[Infinity]}]
(* Plot the solution for t=0, 0.1, 0.2, 0.3 *)
Plot[{u[x, 0], u[x, 0.1], u[x, 0.2], u[x, 0.3]},{x, -5, 5},PlotRange -> All]
Xn''[x]==(x^2-n) Xn[x]
I think! $\endgroup$Xn
should solveXn''[x]==(x^2-n) Xn[x]
$\endgroup$DEigensystem
to find the eigenvalues and eigenfunctions. As mentioned in the answer to your question [mathematica.stackexchange.com/questions/282594/… it is not possible to analytically solve this eigenvalue BVP to find the eigenvalues $\lambda$. But can be done numerically. $\endgroup$