In[]:=
Clear["Global`*"];
(*Υλοποίησητουτύπου(2)τηςσελίδας196γιααρχικήσυνθήκηf(x)=δ(x)*)
Defintion of the function f[x]
In[]:=
f[x_]:=
Sin[x]
x
In[]:=
c[k_]=FourierTransform[f[x],x,k,FourierParameters{-1,-1}]
Out[]=
1
4
1
4
In[]:=
(*Υλοποίησητουτύπου(1)τηςσελίδας196έχονταςυπολογίσειτοΜ/ΣFourierc(k)τηςαρχικήςσυνθήκηςκαιεύρεσητουτύπου(7)τηςσελίδας198*)
In[]:=
u[x_,t_]=InverseFourierTransformc[k],k,x,FourierParameters{-1,-1}
-t
2
k
Out[]=
-
2
x
4t
π
Erft
-x
2
t
t
+x
2
t
4
t
In[]:=
u[x_,t_]:=+Erf
-
2
x
4t
π
Erft
-x
2
t
t
+x
2
t
4
t
The 3-D graph of the analytical solution of the problem
In[]:=
Plot3D[u[x,t],{x,-15,15},{t,0.001,10},PlotRangeAll,ColorFunction"BrightBands"]
Out[]=
Graphs of f[x], u[x, 0.1], u[x, 0.2], u[x, 0.3]
In[]:=
p1=Plot[f[x],{x,-15,15},PlotRangeAll,PlotStyle{Red}]
Out[]=
In[]:=
p2=Plot[u[x,0.1],{x,-15,15},PlotRangeAll,PlotStyle{Blue}]
Out[]=
In[]:=
p3=Plot[u[x,0.2],{x,-15,15},PlotRangeAll,PlotStyle{Yellow}]
Out[]=
In[]:=
p4=Plot[u[x,0.3],{x,-15,15},PlotRangeAll,PlotStyle{Green}]
Out[]=
The graphs on the same axis
In[]:=
Show[p1,p2,p3,p4]
Out[]=
In[]:=
Animate[Plot[u[x,t],{x,-15,15},PlotRangeAll,PlotStyle{Red,Thick}],{t,0.1,10,0.1},AnimationRunningFalse]
Out[]=
In[]:=
Animate[Plot3D[u[x,t],{x,-15,15},{t,0.1,10},PlotRangeAll,ColorFunction"BrightBands"],{t,0.1,10,0.001},AnimationRunningFalse]
Out[]=
