In[]:=
kdv=D[u[x,t],t]+6*u[x,t]*D[u[x,t],x]+D[u[x,t],{x,3}]==0;
Out[]=
-
7
3
′
f
-
7t
3
+x+6f-
7t
3
+x
′
f
-
7t
3
+x+
(3)
f
-
7t
3
+x0
In[]:=
u[x_,t_]:=f[x-c*t];
In[]:=
kdvTraveling=kdv/.u->Function[{x,t},f[x-c*t]];
In[]:=
kdvODE=Simplify[kdvTraveling/.x-c*t->z];
Out[]=
-
7
3
+6f[z]
′
f
[z]+
(3)
f
[z]0
In[]:=
kdvIntegrated=Integrate[kdvODE,z];
Out[]=
-
7
3
+6f[z]
′
f
[z]+
(3)
f
[z]0z
In[]:=
kdvEquation=kdvIntegrated==C[1];
Out[]=
-
7
3
+6f[z]
′
f
[z]+
(3)
f
[z]0z

1
In[]:=
solitonForm=A*Sech[k*z]^2;
Out[]=
2
2
Sech[z]
In[]:=
solitonEquation=kdvEquation/.f[z]->solitonForm;
Out[]=
-
7
3
+12
2
Sech[z]
′
f
[z]+
(3)
f
[z]0z

1
In[]:=
A=2;​​k=1;
In[]:=
c=k^2+A^2/3;
Out[]=
7
3
In[]:=
sechSolution=A*Sech[k*(x-c*t)]^2;
Out[]=
2
2
Sech
7t
3
-x
In[]:=
Plot[sechSolution/.t->0,{x,-10,10},PlotLabel->"Soliton Solution of KdV Equation",AxesLabel->{"x","u(x,t)"}]
Out[]=
In[]:=
verificationLeft=D[sechSolution,t]+6*sechSolution*D[sechSolution,x]+D[sechSolution,{x,3}];​​verificationRight=0;
Out[]=
-
28
3
2
Sech
7t
3
-x
Tanh
7t
3
-x+48
4
Sech
7t
3
-x
Tanh
7t
3
-x+2-16
4
Sech
7t
3
-x
Tanh
7t
3
-x+8
2
Sech
7t
3
-x
3
Tanh
7t
3
-x
In[]:=
Print["Verification (should be True): ",Simplify[verificationLeft==verificationRight]]
Verification (should be True): Sech
7t
3
-xTanh
7t
3
-x0
In[]:=
mass=Integrate[sechSolution,{x,-Infinity,Infinity}];​​Print["Conservation of mass: ",mass]
Conservation of mass:
4 if
condition
In[]:=
momentum=Integrate[sechSolution^2,{x,-Infinity,Infinity}];​​Print["Conservation of momentum: ",momentum]
Conservation of momentum:
16
3
if
condition
In[]:=
energy=Integrate[sechSolution^3-1/2*(D[sechSolution,x])^2,​​{x,-Infinity,Infinity}];​​Print["Conservation of energy: ",energy]
Conservation of energy:
32
5
if
condition