<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.wikiwaves.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rua</id>
	<title>WikiWaves - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.wikiwaves.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rua"/>
	<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php/Special:Contributions/Rua"/>
	<updated>2026-04-17T18:13:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Traffic_Waves&amp;diff=13039</id>
		<title>Traffic Waves</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Traffic_Waves&amp;diff=13039"/>
		<updated>2010-11-14T00:13:38Z</updated>

		<summary type="html">&lt;p&gt;Rua: /* Speed of the shock */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{nonlinear waves course&lt;br /&gt;
 | chapter title = Traffic Waves&lt;br /&gt;
 | next chapter = [[Nonlinear Shallow Water Waves]]&lt;br /&gt;
 | previous chapter = [[Method of Characteristics for Linear Equations]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{complete pages}}&lt;br /&gt;
&lt;br /&gt;
We consider here some simple equations which model traffic flow. This problem is discussed in&lt;br /&gt;
[[Billingham and King 2000]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Reference]]&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We consider a single lane of road, and we measure distance along the road with &lt;br /&gt;
the variable &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; is time. &lt;br /&gt;
We define the following variables&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\begin{matrix}&lt;br /&gt;
&amp;amp;\rho(x,t) &amp;amp;: &amp;amp;\mbox{car density (cars/km)} \\&lt;br /&gt;
&amp;amp; v(\rho)         &amp;amp;: &amp;amp;\mbox{car velocity (km/hour)} \\&lt;br /&gt;
&amp;amp; q(x,t) =\rho v         &amp;amp;: &amp;amp;\mbox{car flow rate (cars/hour)}  \\&lt;br /&gt;
\end{matrix} &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we consider a finite length of road &amp;lt;math&amp;gt;x_1\leq x \leq x_2&amp;lt;/math&amp;gt; then the net flow of cars&lt;br /&gt;
in and out must be balanced by the change in density. This means that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial}{\partial t} \int_{x_1}^{x_2} \rho(x,t) \mathrm{d}x = -q(x_2,t) + q(x_1,t)&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
We now consider continuous densities (which is obviously an approximation) and &lt;br /&gt;
set &amp;lt;math&amp;gt;x_2 = x_1 + \Delta x&amp;lt;/math&amp;gt; and we obtain &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial}{\partial t} \rho(x_1,t) = -\frac{q(x_2,t) + q(x_1,t)}{\Delta x}&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
and if we take the limit as &amp;lt;math&amp;gt;\Delta x \to 0&amp;lt;/math&amp;gt; we obtain the differential equation&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial \rho}{\partial t}  + \frac{\partial q}{\partial x} = 0&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
Note that this equation has been derived purely from the need to conserve cars (it is a conservation equation) and &lt;br /&gt;
is not possible to solve this equation until we have derived a connection between &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;&lt;br /&gt;
and &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
== Equation for &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; only ==&lt;br /&gt;
&lt;br /&gt;
At the moment we assume that we have some expression for &amp;lt;math&amp;gt;v(\rho)&amp;lt;/math&amp;gt;&lt;br /&gt;
If we substitute the expression for &amp;lt;math&amp;gt;q = v\rho&amp;lt;/math&amp;gt; into our differential equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial \rho}{\partial t}  + \frac{\partial }{\partial x} \left(v(\rho)\rho\right) = 0&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
which gives us &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial \rho}{\partial t}  + \left(v^{\prime}(\rho)\rho + v(\rho)\right)&lt;br /&gt;
\frac{\partial \rho }{\partial x} = 0&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
or &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial \rho}{\partial t}  + c(\rho)\frac{\partial \rho }{\partial x} = 0&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;c(\rho) =  \left(v^{\prime}(\rho)\rho + v(\rho)\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
is the &#039;&#039;&#039;kinematic wave speed&#039;&#039;&#039;. Note that this is not the speed of the cars, but&lt;br /&gt;
the speed at which disturbances in the density travel.&lt;br /&gt;
&lt;br /&gt;
== A simple relationship between &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The relationship between &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; is an equation of state and&lt;br /&gt;
there is no &#039;&#039;exact&#039;&#039; equation since it depends on many unknowns. One of the&lt;br /&gt;
simplest relationship between &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; is derived from&lt;br /&gt;
the following assumptions&lt;br /&gt;
&lt;br /&gt;
* When the density &amp;lt;math&amp;gt;\rho = 0&amp;lt;/math&amp;gt; the speed is &amp;lt;math&amp;gt;v=v_0&amp;lt;/math&amp;gt;&lt;br /&gt;
* When the density is &amp;lt;math&amp;gt;\rho = \rho_{\max} &amp;lt;/math&amp;gt; the speed is &amp;lt;math&amp;gt;v=0&amp;lt;/math&amp;gt;&lt;br /&gt;
* The speed is a linear function of &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; between these two values. &lt;br /&gt;
&lt;br /&gt;
This also gives good fit with measured data. We will either consider the general case or use this simple&lt;br /&gt;
relationship. Using this we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
v(\rho) = v_0\frac{\rho_{\max} - \rho}{\rho_{\max}}&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The flux of cars is given by &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
q = \rho v(\rho) = v_0\frac{\rho(\rho_{\max} - \rho)}{\rho_{\max}}&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
and the wave speed is &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
c(\rho) =  \left(v^{\prime}(\rho)\rho + v(\rho)\right) = -\frac{v_0}{\rho_{\max}}\rho + v_0\frac{\rho_{\max} - \rho}{\rho_{\max}}&lt;br /&gt;
= v_0\frac{\rho_{\max} - 2\rho}{\rho_{\max}}&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Velocity.jpg|thumb|350px|&amp;lt;math&amp;gt;v(\rho)&amp;lt;/math&amp;gt; versus &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;]]&lt;br /&gt;
| [[Image:Q_flux.jpg|thumb|350px|&amp;lt;math&amp;gt;q(\rho)&amp;lt;/math&amp;gt; versus &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;]]&lt;br /&gt;
| [[Image:C_speed.jpg|thumb|350px|&amp;lt;math&amp;gt;\rho(\rho)&amp;lt;/math&amp;gt; versus &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Small Amplitude Disturbances ==&lt;br /&gt;
&lt;br /&gt;
We can linearise the model by assuming that the variation in density is small so &lt;br /&gt;
that we can write&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho = \rho_0 + \tilde{\rho}&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we assume that &amp;lt;math&amp;gt;\tilde{\rho}&amp;lt;/math&amp;gt; is small. This allows us to write the equations as&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial \tilde{\rho}}{\partial t}  + c(\rho_0) \frac{\partial \tilde{\rho}}{\partial x}  = 0&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where the main difference between this and the full equation is that the wave speed &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; is&lt;br /&gt;
a constant. This is the linearised equation. Note that this linearisation does not give a good model because &lt;br /&gt;
traffic density does not vary only a small amount about some mean (as is the case for accoustic waves where the &lt;br /&gt;
density of air is roughly constant). &lt;br /&gt;
&lt;br /&gt;
Under these assumptions the solution to the equation is &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\tilde{\rho} = f(x - c(\rho_0)t) &lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;f&amp;lt;/math&amp;gt; is determined by the initial condition. This represents &lt;br /&gt;
disturbances which travel with speed &amp;lt;math&amp;gt;c(\rho_0)&amp;lt;/math&amp;gt; in the positive&lt;br /&gt;
&amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction. &lt;br /&gt;
&lt;br /&gt;
We now consider the &#039;&#039;&#039;characteristic curves&#039;&#039;&#039; which are curves along which the density&lt;br /&gt;
&amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; is a constant. These are give by &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
x = X(t) = x_0 + c(\rho_0) t.\,&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
which are just straight lines of constant slope.  We will see shortly that the full (nonlinear)&lt;br /&gt;
equations also possess characteristics.&lt;br /&gt;
&lt;br /&gt;
== Nonlinear Initial Value Problem == &lt;br /&gt;
&lt;br /&gt;
We wish to solve &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial \rho}{\partial t}  + c(\rho) \frac{\partial \rho}{\partial x}  = 0&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the initial conditions&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,0) = \rho_0(x) \,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
It turns out that the concept of characteristic curves is very important for this problem. &lt;br /&gt;
&lt;br /&gt;
If we want &amp;lt;math&amp;gt;\rho(X(t),t)&amp;lt;/math&amp;gt; to be a constant then we require&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\mathrm{d}}{\mathrm{d}t}\rho(X(t),t) = \frac{\mathrm{d} X}{\mathrm{d}t} \frac{\partial \rho}{\partial x} + &lt;br /&gt;
\frac{\partial \rho}{\partial t} = 0. &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
Comparing this to the governing partial differential equation we can see that we require&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\mathrm{d} X}{\mathrm{d}t}  = c(\rho) &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
This means that the characteristics are straight lines (since &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; is constant) with&lt;br /&gt;
slope given by &amp;lt;math&amp;gt; c(\rho_0(x_0))&amp;lt;/math&amp;gt; so that the equation for the characteristics is &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
X(t)  = x_0 + c(\rho_0(x_0))t \,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This does not allow us to write down a solution to the initial value problem,&lt;br /&gt;
all we can do is write&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x_0 + c(\rho_0(x_0))t,t) = \rho_0(x_0)\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
which allows us to calculate the solution stepping forward in time, but not to determine the solution given&lt;br /&gt;
a value of &amp;lt;math&amp;gt;(x,t)&amp;lt;/math&amp;gt; (because we have no way of knowing what &amp;lt;math&amp;gt;c(\rho_0(x_0))&amp;lt;/math&amp;gt; is.  &lt;br /&gt;
&lt;br /&gt;
The characteristics are a family of straight lines which will all have different slopes. If two characteristics&lt;br /&gt;
meet, our solution method will break down because there will be two values of the density &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;. &lt;br /&gt;
This gives rise to a &#039;&#039;&#039;shock&#039;&#039;&#039;. It turns&lt;br /&gt;
out that this the formation of shocks is a product of the equations themselves and not with the solution method.&lt;br /&gt;
We will see shortly that special methods are required to treat these shocks. &lt;br /&gt;
&lt;br /&gt;
=== Case when no shocks are formed ===&lt;br /&gt;
&lt;br /&gt;
The characteristic curves will fill the space without meeting provided that the wave speed &amp;lt;math&amp;gt;c(\rho_0)&amp;lt;/math&amp;gt;&lt;br /&gt;
is a monotonically increasing function of the distance &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;. If we work with our previous model we&lt;br /&gt;
have &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
v(\rho) = v_0\frac{\rho_{\max} - \rho}{\rho_{\max}}&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
and &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
c(\rho) = v_0\frac{\rho_{\max} - 2\rho}{\rho_{\max}}&lt;br /&gt;
 &amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
so that &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt; is a monotonically decreasing function of density &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;. This means&lt;br /&gt;
that the wave speed &amp;lt;math&amp;gt;c(\rho_0)&amp;lt;/math&amp;gt; will be&lt;br /&gt;
a monotonically increasing function of the distance &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; if an only if the density is a&lt;br /&gt;
monotonically decreasing function. In this case the solution can be calculated straightforwardly &lt;br /&gt;
by expansion of the initial density. &lt;br /&gt;
&lt;br /&gt;
==== No shock example ====&lt;br /&gt;
&lt;br /&gt;
We consider the case when &amp;lt;math&amp;gt;\rho_{\max} = v_0 = 1&amp;lt;/math&amp;gt; and where the initial density is given&lt;br /&gt;
by &amp;lt;math&amp;gt;\rho_0 = 1/2(1- \tanh(x))&amp;lt;/math&amp;gt;. The figures below show the initial density, the initial speed,&lt;br /&gt;
the characteristics and &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt; for this case.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Traffic example1 rho.jpg|thumb|350px| &amp;lt;math&amp;gt;\rho_0 = 1/2(1- \tanh(x))&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
| [[Image:Traffic_example1_c.jpg|thumb|350px|&amp;lt;math&amp;gt;c(\rho_0)&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! characteristics&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Traffic_example1_characteristics.jpg|thumb|350px|Characterisitics for  &amp;lt;math&amp;gt;\rho_0 = 1/2(1- \tanh(x))&amp;lt;/math&amp;gt;]]&lt;br /&gt;
| [[Image:Traffic_example11.gif|thumb|350px|&amp;lt;math&amp;gt;\rho(x,t) for &amp;lt;/math&amp;gt;&amp;lt;math&amp;gt;\rho_0 = 1/2(1- \tanh(x))&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Riemann problem and the expansion fan ====&lt;br /&gt;
&lt;br /&gt;
We can consider a simple problem in which there is a jump in the initial density&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,0) = &lt;br /&gt;
\left\{&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
\rho_{L},&amp;amp; x &amp;lt; 0 \\&lt;br /&gt;
\rho_{R},&amp;amp; x &amp;gt; 0 &lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;\rho_{L} &amp;gt; \rho_{R}&amp;lt;/math&amp;gt; so that we do not form a shock. In this case&lt;br /&gt;
the characteristics on each side of &amp;lt;math&amp;gt;x=0&amp;lt;/math&amp;gt; have a different slope and the &lt;br /&gt;
question is what happens between. It is easiest to think about the following problem&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,0) = &lt;br /&gt;
\left\{&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
\rho_{L},&amp;amp; x &amp;lt; -\epsilon \\&lt;br /&gt;
\frac{\rho_{R}-\rho_{L}}{2\epsilon}x + \frac{\rho_{R}+\rho_{L}}{2} &amp;amp; -\epsilon \leq x \leq \epsilon \\&lt;br /&gt;
\rho_{R},&amp;amp; x &amp;gt; \epsilon &lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
We can then see that we have lines of uniformly varying slope for &amp;lt;math&amp;gt;-\epsilon&amp;lt;x&amp;lt;\epsilon&amp;lt;/math&amp;gt;&lt;br /&gt;
with slope between &amp;lt;math&amp;gt;c(\rho_L)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;c(\rho_R)&amp;lt;/math&amp;gt;. If we then take the limit&lt;br /&gt;
as &amp;lt;math&amp;gt;\epsilon \to 0&amp;lt;/math&amp;gt; we obtain an expansion fan emanating from &amp;lt;math&amp;gt;x=0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If we assume that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
c(\rho) = v_0\frac{\rho_{\max} - 2\rho}{\rho_{\max}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
then we know that on the lines of the expansion fan (which all start at &amp;lt;math&amp;gt;x=0&amp;lt;/math&amp;gt;) we have&lt;br /&gt;
&amp;lt;math&amp;gt;c(\rho) = x/t&amp;lt;/math&amp;gt;. We can rearrange this and solve for &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; and obtain&lt;br /&gt;
&amp;lt;math&amp;gt;\rho =\frac{ 1}{2} \rho_{\max} (1-x/v_0 t)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The solution is then given by  &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,t) = &lt;br /&gt;
\left\{&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
\rho_{L},&amp;amp; x &amp;lt; c(\rho_L) t\\&lt;br /&gt;
\frac{ \rho_{\max}}{2} (1-x/v_0 t),&amp;amp; c(\rho_L) t \leq x \leq  c(\rho_R) t\\&lt;br /&gt;
\rho_{R},&amp;amp; x &amp;gt;  c(\rho_R) t&lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
This solution is known as an &#039;&#039;&#039;expansion fan&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We consider the case when &amp;lt;math&amp;gt;\rho_{\max} = v_0 = 1&amp;lt;/math&amp;gt; and where the initial density is given&lt;br /&gt;
by &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,0) = &lt;br /&gt;
\left\{&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
0.6,&amp;amp; x &amp;lt; 0 \\&lt;br /&gt;
0.3,&amp;amp; x &amp;gt; 0 &lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;. The figures below show the initial density, the initial speed,&lt;br /&gt;
the characteristics and &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt; for this case.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Expansion_fan_rho.jpg|thumb|350px| &amp;lt;math&amp;gt;\rho_0&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
| [[Image:Expansion_fan_c.jpg|thumb|350px|&amp;lt;math&amp;gt;c(\rho_0)&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! characteristics&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Expansion_fan_characteristics.jpg|thumb|350px|Characterisitics]]&lt;br /&gt;
| [[Image:Expansion_fan1.gif|thumb|350px|&amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Shocks ===&lt;br /&gt;
&lt;br /&gt;
So far we have only considered the case when &amp;lt;math&amp;gt;c(x_0)&amp;lt;/math&amp;gt; is monotonically increasing so that&lt;br /&gt;
two characteristics never cross. We now consider the case when characteristics can meet. &lt;br /&gt;
A movie of this case is shown below. &lt;br /&gt;
&lt;br /&gt;
{{#ev:youtube|Suugn-p5C1M}}&lt;br /&gt;
&lt;br /&gt;
We can easily see that&lt;br /&gt;
the first characteristics to meet will be neighbouring characteristics. Consider two characteristics&lt;br /&gt;
with &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
X_1(t) = x_0 + c(x_0)t\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt; &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
X_2(t) = x_0 + \delta x + c(x_0+\delta x)t\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt; &lt;br /&gt;
Then these curves will meet at time &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; where &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
x_0 + c(x_0)T = x_0 + \delta x + c(x_0+\delta x)T\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt; &lt;br /&gt;
which implies that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
T = -\frac{1}{c^{\prime}(x_0)}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt; &lt;br /&gt;
Note the following&lt;br /&gt;
* If &amp;lt;math&amp;gt;c^{\prime}(x) &amp;gt; 0 &amp;lt;/math&amp;gt; then no shock will form. &lt;br /&gt;
* The shock first forms at the minimum positive value of &lt;br /&gt;
&amp;lt;math&amp;gt; - \frac{1}{c^{\prime}(x)} &amp;lt;/math&amp;gt;  for &amp;lt;math&amp;gt; -\infty &amp;lt; x &amp;lt;\infty &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Shock Fitting ====&lt;br /&gt;
&lt;br /&gt;
If we calculate the solution using our formula &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x_0 + c(\rho_0(x_0))t,t) = \rho(x_0)\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
then we find that the solution becomes multivalued in the case when a shock forms.&lt;br /&gt;
We then have to fit a shock. One way to do this is by imposing the condition that equal&lt;br /&gt;
areas are removed and added when we chose the position of the shock. &lt;br /&gt;
This corresponds to the condition that&lt;br /&gt;
the number of cars must be conserved&lt;br /&gt;
&lt;br /&gt;
==== Speed of the shock ====&lt;br /&gt;
&lt;br /&gt;
If we consider the case when there is a shock at &amp;lt;math&amp;gt;s(t)&amp;lt;/math&amp;gt; with &lt;br /&gt;
&amp;lt;math&amp;gt;\rho = \rho^{-}&amp;lt;/math&amp;gt; at &amp;lt;math&amp;gt;x=s^{-}&amp;lt;/math&amp;gt; &lt;br /&gt;
and &lt;br /&gt;
&amp;lt;math&amp;gt;\rho = \rho^{+}&amp;lt;/math&amp;gt; at &amp;lt;math&amp;gt;x=s^{+}&amp;lt;/math&amp;gt;&lt;br /&gt;
(where &amp;lt;math&amp;gt;s^{-}&amp;lt;/math&amp;gt;&lt;br /&gt;
is just less than s(t) and &amp;lt;math&amp;gt;s^{+}&amp;lt;/math&amp;gt;&lt;br /&gt;
is just greater than s(t) ). If we substitute&lt;br /&gt;
this into the governing integral equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\partial}{\partial t} \left( \int_{x_1}^{s(t)} + \int_{s(t)}^{x_2}\right)&lt;br /&gt;
 \rho(x,t)\mathrm{d}x = q(x_1,t) - q(x_2,t)&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
and hence&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
 \int_{x_1}^{x_2}&lt;br /&gt;
\frac{\partial \rho(x,t)}{\partial t} \mathrm{d}x + \frac{\mathrm{d}s}{\mathrm{d}t}\rho^{-} &lt;br /&gt;
- \frac{\mathrm{d}s}{\mathrm{d}t}\rho^{+}  = q(x_1,t) - q(x_2,t)&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
If we now take the limit as &amp;lt;math&amp;gt;x_1\to x_2&amp;lt;/math&amp;gt; we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\mathrm{d}s}{\mathrm{d}t}\rho^{-} &lt;br /&gt;
- \frac{\mathrm{d}s}{\mathrm{d}t}\rho^{+}  = q(\rho^{-}) - q(\rho^{+})&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
so that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\frac{\mathrm{d}s}{\mathrm{d}t} = \frac{q(\rho^{-}) - q(\rho^{+})}&lt;br /&gt;
{\rho^{-} - \rho^{+}}  &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Shock example ====&lt;br /&gt;
&lt;br /&gt;
We consider the case when &amp;lt;math&amp;gt;\rho_{\max} = v_0 = 1&amp;lt;/math&amp;gt; and where the initial density is given&lt;br /&gt;
by &amp;lt;math&amp;gt;\rho_0 = 1/2(1 + \tanh(x))&amp;lt;/math&amp;gt;. The figures below show the initial density, the initial speed,&lt;br /&gt;
the characteristics and &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt; for this case.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Traffic example2 rho.jpg|thumb|350px| &amp;lt;math&amp;gt;\rho_0 = 1/2(1+ \tanh(x))&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
| [[Image:Traffic_example2_c.jpg|thumb|350px|&amp;lt;math&amp;gt;c(\rho_0)&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! characteristics&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Traffic_example2_characteristics.jpg|thumb|350px|Characterisitics for  &amp;lt;math&amp;gt;\rho_0 = 1/2(1+ \tanh(x))&amp;lt;/math&amp;gt;]]&lt;br /&gt;
| [[Image:Traffic_example2.gif|thumb|350px|&amp;lt;math&amp;gt;\rho(x,t) for &amp;lt;/math&amp;gt;&amp;lt;math&amp;gt;\rho_0 = 1/2(1+ \tanh(x))&amp;lt;/math&amp;gt; Dotted solution is without shock fitting.]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Riemann problem ====&lt;br /&gt;
&lt;br /&gt;
We now consider the Riemann problem &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,0) = &lt;br /&gt;
\left\{&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
\rho_{L},&amp;amp; x &amp;lt; 0 \\&lt;br /&gt;
\rho_{R},&amp;amp; x &amp;gt; 0 &lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;\rho_{L} &amp;lt; \rho_{R}&amp;lt;/math&amp;gt;. In this case a shock forms immediately and&lt;br /&gt;
the characteristics terminate at the shock. The shock moves with constant speed given by&lt;br /&gt;
the equation for the motion of the shock (or can be found by the equal areas rule). We obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,t) = &lt;br /&gt;
\left\{&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
\rho_{L},&amp;amp; x &amp;lt; \frac{1}{2} \left(c(\rho_{L}) + c(\rho_{R}) \right) t  \\&lt;br /&gt;
\rho_{R},&amp;amp; x &amp;gt; \frac{1}{2} \left(c(\rho_{L}) + c(\rho_{R}) \right) t &lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We consider the case when &amp;lt;math&amp;gt;\rho_{\max} = v_0 = 1&amp;lt;/math&amp;gt; and where the initial density is given&lt;br /&gt;
by &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt; &lt;br /&gt;
\rho(x,0) = &lt;br /&gt;
\left\{&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
0.3,&amp;amp; x &amp;lt; 0 \\&lt;br /&gt;
0.6,&amp;amp; x &amp;gt; 0 &lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The figures below show the initial density, the initial speed,&lt;br /&gt;
the characteristics, and &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt; for this case.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt;&lt;br /&gt;
! &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Shock_rho.jpg|thumb|350px| &amp;lt;math&amp;gt;\rho_0&amp;lt;/math&amp;gt; ]]&lt;br /&gt;
| [[Image:Shock_c.jpg|thumb|350px|&amp;lt;math&amp;gt;c(\rho_0)&amp;lt;/math&amp;gt;]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! characteristics&lt;br /&gt;
! &amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Shock_characteristics.jpg|thumb|350px|Characterisitics with shock shown in green.]]&lt;br /&gt;
| [[Image:Shock3.gif|thumb|350px|&amp;lt;math&amp;gt;\rho(x,t)&amp;lt;/math&amp;gt; with the red dotted line showing the solution without shock fitting]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Simple Nonlinear Waves]]&lt;/div&gt;</summary>
		<author><name>Rua</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Numerical_Solution_of_the_KdV&amp;diff=13021</id>
		<title>Numerical Solution of the KdV</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Numerical_Solution_of_the_KdV&amp;diff=13021"/>
		<updated>2010-11-09T03:58:40Z</updated>

		<summary type="html">&lt;p&gt;Rua: /* Numerical Solution of the KdV */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{nonlinear waves course&lt;br /&gt;
 | chapter title = Numerical Solution of the KdV&lt;br /&gt;
 | next chapter = [[Conservation Laws for the KdV]]&lt;br /&gt;
 | previous chapter = [[Introduction to KdV]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We present here a method to solve the KdV equation numerically. There are&lt;br /&gt;
many different methods to solve the KdV and we use here a spectral method&lt;br /&gt;
which has been found to work well. Spectral methods work by using the&lt;br /&gt;
Fourier transform (or some varient of it) to calculate the derivative.&lt;br /&gt;
&lt;br /&gt;
==Fourier Transform==&lt;br /&gt;
&lt;br /&gt;
Recall that the Fourier transform is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\mathcal{F}\left[ f(x)\right] =\hat{f}\left( k\right) =\int_{-\infty&lt;br /&gt;
}^{\infty }f\left( x\right) \mathrm{e}^{-\mathrm{i}kx}\mathrm{d}x &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
and the inverse Fourier transform is given by &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
f\left( x\right) =\mathcal{F}^{-1}\left[ \hat{f}\left( k\right) \right] =&lt;br /&gt;
\frac{1}{2\pi }\int_{-\infty }^{\infty }\hat{f}\left( k\right) \mathrm{e}^{\mathrm{i}kx}\mathrm{d}k &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
(note that there are other ways of writing this transform). The most&lt;br /&gt;
important property of the Fourier transform is that&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\begin{matrix}&lt;br /&gt;
\int_{-\infty }^{\infty }\left( \partial _{x}f\left( x\right) \right)&lt;br /&gt;
\mathrm{e}^{-\mathrm{i}kx}\mathrm{d}x &amp;amp;=&amp;amp;-\int_{-\infty }^{\infty }f\left( x\right) &lt;br /&gt;
\left( \partial_{x}\mathrm{e}^{-\mathrm{i}kx}\right) \mathrm{d}x \\&lt;br /&gt;
&amp;amp;=&amp;amp;-k\int_{-\infty }^{\infty }f\left( x\right) \mathrm{e}^{-\mathrm{i}kx}\mathrm{d}x&lt;br /&gt;
\end{matrix}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that the function &amp;lt;math&amp;gt;f\left( x\right) &amp;lt;/math&amp;gt; vanishes at &amp;lt;math&amp;gt;\pm&lt;br /&gt;
\infty .&amp;lt;/math&amp;gt; This means that the Fourier transform converts differentiation to&lt;br /&gt;
multiplication by &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Solution for the Linearized KdV==&lt;br /&gt;
&lt;br /&gt;
We begin with a simple example. Suppose we want to solve the linearized KdV&lt;br /&gt;
equation &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial _{t}u+\partial _{x}^{3}u=0,\ \ -\infty &amp;lt;x&amp;lt;\infty &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to solve initial conditions &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
u\left( x,0\right) =f\left( x\right) &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
We can solve this equation by taking the Fourier transform. and obtain &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial _{t}\hat{u}-ik^{3}\hat{u}=0 &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
So that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\hat{u}\left( k,t\right) =\hat{f}\left( k\right) \mathrm{e}^{\mathrm{i}k^{3}t} &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
Therefore &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
u\left( x,t\right) = \frac{1}{2\pi}&lt;br /&gt;
\int_{-\infty}^{\infty }\hat{f}\left( k\right)&lt;br /&gt;
\mathrm{e}^{\mathrm{i}k^{3}t}\mathrm{e}^{\mathrm{i}kx}\mathrm{d}k &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Numerical Implementation Using the FFT==&lt;br /&gt;
&lt;br /&gt;
The Fast Fourier Transform (FFT) is a method to calculate the fourier&lt;br /&gt;
transform efficiently for discrete sets of points. These points need to be&lt;br /&gt;
evenly spaced in the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; plane and are given by &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
x_{n}=x_{0}+n\Delta x,\ \ 0\leq n\leq N-1 &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
(note they can start at any &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; value). For the FFT to be as efficient as&lt;br /&gt;
possible &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; should be a power of &amp;lt;math&amp;gt;2.&amp;lt;/math&amp;gt; Corresponding to the discrete set of&lt;br /&gt;
points in the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; domain is a discrete set of points in the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; plane given&lt;br /&gt;
by &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
k_{n}=\left\{ &lt;br /&gt;
\begin{matrix}&lt;br /&gt;
n\Delta k,\ \ 0\leq n\leq \frac{N}{2} \\ &lt;br /&gt;
\left( n-N\right) \Delta k,\ \ \frac{N}{2}+1\leq n\leq N-1&lt;br /&gt;
\end{matrix}&lt;br /&gt;
\right. &lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where &amp;lt;math&amp;gt;\Delta k=2\pi /(N\Delta x).&amp;lt;/math&amp;gt; Note that this numbering seems slighly&lt;br /&gt;
odd and is due to aliasing. We are not that interested in the frequency&lt;br /&gt;
domain solution but we need to make sure that we select the correct values&lt;br /&gt;
of &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; for our numerical code.&lt;br /&gt;
&lt;br /&gt;
==Numerical Code for the Linear KdV==&lt;br /&gt;
&lt;br /&gt;
Here is the code to solve the linear KdV using MATLAB&lt;br /&gt;
&lt;br /&gt;
N = 1024;&lt;br /&gt;
&lt;br /&gt;
t=0.1;&lt;br /&gt;
&lt;br /&gt;
x = linspace(-10,10,N);&lt;br /&gt;
&lt;br /&gt;
delta_x = x(2) - x(1);&lt;br /&gt;
&lt;br /&gt;
delta_k = 2*pi/(N*delta_x);&lt;br /&gt;
&lt;br /&gt;
k = [0:delta_k:N/2*delta_k,-(N/2-1)*delta_k:delta_k:-delta_k];&lt;br /&gt;
&lt;br /&gt;
f = exp(-x.^2);&lt;br /&gt;
&lt;br /&gt;
f_hat = fft(f);&lt;br /&gt;
&lt;br /&gt;
u = real(ifft(f_hat.*exp(i*k.^3*t)));&lt;br /&gt;
&lt;br /&gt;
==Numerical Solution of the KdV==&lt;br /&gt;
&lt;br /&gt;
It turns out that a method to solve the KdV equation can be derived using&lt;br /&gt;
spectral methods. We begin with the KdV equation written as&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial _{t}u+3\partial _{x}\left( u\right) ^{2}+\partial _{x}^{3}u=0.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The Fourier transform of the KdV is therefore &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial _{t}\hat{u}+3ik\widehat{\left( u^{2}\right)} -ik^{3}\hat{u}=0&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
We solve this equation by a split step method. We write the equation as  &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial _{t}\hat{u}=-3ik\widehat{\left( u^{2}\right)} +ik^{3}\hat{u}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
We can solve &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial _{t}\hat{u}=ik^{3}\hat{u}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
exactly while the equation &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial _{t}\hat{u}=-3ik\widehat{\left( u^{2}\right)}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
needs to be solved by time stepping. The idea of the split step method is to&lt;br /&gt;
solve alternatively each of these equations when stepping from &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;&lt;br /&gt;
t+\Delta t.&amp;lt;/math&amp;gt; Therefore we solve &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\begin{matrix}&lt;br /&gt;
\hat{u}_{1}\left( k,t+\Delta t\right)  &amp;amp;=&amp;amp;\hat{u}\left( k,t\right)&lt;br /&gt;
\mathrm{e}^{\mathrm{i}k^{3}\Delta t} \\&lt;br /&gt;
\hat{u}\left( k,t+\Delta t\right)  &amp;amp;=&amp;amp;\hat{u}_{1}\left( k,t+\Delta t\right)&lt;br /&gt;
-3ik \Delta t\widehat{\left( u_{1}^{2}\right)}&lt;br /&gt;
\end{matrix}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
Note that we are using Euler&#039;s method to time step and that the solution&lt;br /&gt;
could be improved by using a better method, such as the Runge-Kutta 4&lt;br /&gt;
method. &lt;br /&gt;
&lt;br /&gt;
The only slighly tricky thing is that we have both &amp;lt;math&amp;gt;u&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{u}&amp;lt;/math&amp;gt; in the&lt;br /&gt;
equation, but we can simply use the Fourier transform to connect these. The&lt;br /&gt;
equation then becomes&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;\begin{matrix}&lt;br /&gt;
\hat{u}_{1}\left( k,t+\Delta t\right)  &amp;amp;=&amp;amp;\hat{u}\left( k,t\right)&lt;br /&gt;
\mathrm{e}^{\mathrm{i}k^{3}\Delta t} \\&lt;br /&gt;
\hat{u}\left( k,t+\Delta t\right)  &amp;amp;=&amp;amp;\hat{u}_{1}\left( k,t+\Delta t\right)&lt;br /&gt;
- 3ik\Delta t\left( \mathcal{F}\left( \left( \mathcal{F}^{-1}\left[ \hat{u}_{1}\left( k,t+\Delta t\right)\right]&lt;br /&gt;
\right) ^{2}\right) \right) &lt;br /&gt;
\end{matrix}&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Numerical Code to solve the KdV by the split step method==&lt;br /&gt;
&lt;br /&gt;
Here is some code to solve the KdV using MATLAB &lt;br /&gt;
&lt;br /&gt;
N = 256;&lt;br /&gt;
&lt;br /&gt;
x = linspace(-10,10,N);&lt;br /&gt;
&lt;br /&gt;
delta_x = x(2) - x(1);&lt;br /&gt;
&lt;br /&gt;
delta_k = 2*pi/(N*delta_x);&lt;br /&gt;
&lt;br /&gt;
k = [0:delta_k:N/2*delta_k,-(N/2-1)*delta_k:delta_k:-delta_k];&lt;br /&gt;
&lt;br /&gt;
c=16;&lt;br /&gt;
&lt;br /&gt;
u = 1/2*c*(sech(sqrt(c)/2*(x+8))).^2;&lt;br /&gt;
&lt;br /&gt;
delta_t = 0.4/N^2;&lt;br /&gt;
&lt;br /&gt;
tmax = 0.1; nmax = round(tmax/delta_t);&lt;br /&gt;
&lt;br /&gt;
U = fft(u);&lt;br /&gt;
&lt;br /&gt;
for n = 1:nmax&lt;br /&gt;
&lt;br /&gt;
% first we solve the linear part&lt;br /&gt;
&lt;br /&gt;
U = U.*exp(1i*k.^3*delta_t);&lt;br /&gt;
&lt;br /&gt;
%then we solve the non linear part&lt;br /&gt;
&lt;br /&gt;
U = U - delta_t*(3i*k.*fft(real(ifft(U)).^2));&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
== Example Calculations ==&lt;br /&gt;
We cosider the evolution of the KdV with two solitons as&lt;br /&gt;
initial condition as given below.&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
u(x,0) = 8\,\mathrm{sech}^{2}\left(2(x+8)\right) &lt;br /&gt;
+ \, 2 \mathrm{sech}^{2}\left(\left(&lt;br /&gt;
x +1\right) \right)&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Animation&lt;br /&gt;
! Three-dimensional plot.&lt;br /&gt;
|-&lt;br /&gt;
| [[Image:Two_soliton.gif|thumb|right|500px|Evolution of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; for two solitons.]]&lt;br /&gt;
| [[Image:Two_soliton.jpg|thumb|right|500px|Evolution of &amp;lt;math&amp;gt;u(x,t)&amp;lt;/math&amp;gt; for two solitons. &lt;br /&gt;
Note the phase shift which occurs in the soliton interaction.]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Rua</name></author>
	</entry>
</feed>