Given the following problem -·+··u(x)0 Where are the Eigenfunctions that defined as (x)exp(x)By separation we assume )I have found that the general solution of isand the general solution of $X$ is (x)exp(x)So the general solution to our initial problem is (x,t)exp(x)Using the I.C we got
u
t
v
2
u
xx
v
2
2
x
u(x,0)f(x)
f(x)(x)+0.2(x)+0.01(x)
y
1
y
4
y
6
y
n
y
n
-
2
x
2
H
n
u(x,t)X(x)T(x
T
T(x)
c
1
-λvt
e
X
n
-
2
x
2
H
n
u
n
∞
∑
n1
A
n
-
2
x
2
H
n
c
1
-λvt
e
u(x,0)exp(x)f(x)
∞
∑
n1
A
n
-
2
x
2
H
n
Analytical solution
Analytical solution
In[]:=
Clear["Global`*"]
In[]:=
f[x_]:=Exp[-x^2/2](1+0.2*HermiteH[4,x]+0.01*HermiteH[6,x])n=10;
In[]:=
A=Table[1/(Sqrt[Pi]2^mm!)Integrate[f[x]HermiteH[m,x]Exp[x^2/2],{x,0,1}],{m,1,n}];u[x_,t_]:=Sum[A[[m]]Exp[-m/2t]Exp[-x^2/2]HermiteH[m-1,x],{m,1,n}]
In[]:=
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"}]
Out[]=
In[]:=
fig1=Plot3D[u[x,t],{t,0,10},{x,-21,21},PlotRangeAll,ColorFunction"BlueGreenYellow"]
Out[]=
Numerical Solution
Numerical Solution
In[]:=
Clear["Global`*"]
(*DefinetheEigenfunctions*)
In[]:=
eigen[n_]:=n+1/2
In[]:=
Her[n_]:=HermiteH[n,x]
In[]:=
Y[n_]:=Exp[-x^2/2]*Her[n]
In[]:=
Y[1]
Out[]=
2x
-
2
x
2
In[]:=
Y[4]
Out[]=
-
2
x
2
2
x
4
x
In[]:=
Y[6]
Out[]=
-
2
x
2
2
x
4
x
6
x
(*ThefunctionoftheInitialCondition*)
In[]:=
f[x_]=Y[1]+0.2Y[4]+0.01Y[6]
Out[]=
2x+0.2(12-48+16)+0.01(-120+720-480+64)
-
2
x
2
-
2
x
2
2
x
4
x
-
2
x
2
2
x
4
x
6
x
(*InitialCondition*)
In[]:=
IC=u[x,0]f[x]
Out[]=
u[x,0]2x+0.2(12-48+16)+0.01(-120+720-480+64)
-
2
x
2
-
2
x
2
2
x
4
x
-
2
x
2
2
x
4
x
6
x
(*DefinePDE*)
In[]:=
PDE=u[x,t]-*u[x,t]+**u[x,t]0
∂
t
1
2
∂
x,x
1
2
2
x
Out[]=
1
2
2
x
(0,1)
u
1
2
(2,0)
u
(*BountaryConditions*)
In[]:=
BCs={u[-21,t]==0,u[21,t]==0}
Out[]=
{u[-21,t]0,u[21,t]0}
In[]:=
sol=First[NDSolve[{PDE,BCs,IC},u,{t,0,10},{x,-21,21}]]
Out[]=
uInterpolatingFunction
In[]:=
Plot3D[u[x,t]/.sol,{t,0,10},{x,-21,21},PlotRangeAll,ColorFunction"RustTones"]
Out[]=
In[]:=
Manipulate[Plot[u[x,t]/.sol/.t->t0,{x,-21,21},PlotRange->{Automatic,{-4,4}},GridLines->Automatic,GridLinesStyle->LightGray,PlotStyle->Red],{{t0,0,"time"},0,1,.01,Appearance->"Labeled"}]
Out[]=

