# insufficient boundary condition error

I wish to solve the initial value kdv equation with a boundary condition that particles are fixed at the end points. Below is my code.

sp = 16
d = 1
s = NDSolve[{\!$$\*SubscriptBox[\(\[PartialD]$$, $$t$$]$$u[t, x]$$\) == -u[t, x]*\!$$\*SubscriptBox[\(\[PartialD]$$, $$x$$]$$u[t, x]$$\) - d*\!$$\*SubscriptBox[\(\[PartialD]$$, $$x, x, x$$]$$u[t, x]$$\),
u[0, x] == 3*d^(1/3)*sp*Sech[0.5*Sqrt[sp]*d^(-1/3)*x]^2,
u[t, -100] == u[t, 100] == 0}, u, {t, 0, 4}, {x, -100, 100}]


But it is showing error NDSolve::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution.

I dont get why this is so, as I have explicitly specified that u must be zero at x=-100 and 100 for all t, as particles are fixed there.

You have 3rd order in space and one order in time. Hence need 3 BC in space and one initial condition for numerical solution. You only provided 2 BC in space.

This is what

\Warning: an insufficient number of boundary conditions have been specified

is saying.

I made an extra BC up for space. Feel free to change it as needed. for your physics.

It is also better to write the ic and the bc and the pde in separate lines so your code is easier to read.

ClearAll[x, t, u];
sp = 16
d = 1
ic = u[0, x] == 3*d^(1/3)*sp*Sech[1/2*Sqrt[sp]*d^(-1/3)*x]^2;
bc = {u[t, -100] == 0, u[t, 100] == 0, Derivative[0, 1][u][t, 100] == 0};
pde = D[u[t, x], t] == -u[t, x]*D[u[t, x], x] - d*D[u[t, x], {x, 3}];

s = NDSolve[{pde, ic, bc}, u, {t, 0, 4}, {x, -100, 100},
Method -> "StiffnessSwitching"]


Plot3D[Evaluate[u[t, x] /. s], {t, 0, 4}, {x, -100, 100},
PlotRange -> All]


The three constants of integration are seen by solving the PDE using DSolve

  DSolve[pde, u[t, x], {t, x}]


$$\left\{\left\{u(t,x)\to -\frac{12 c_2{}^3 \tanh ^2(c_1 t+c_2 x+c_3)-8 c_2{}^3+c_1}{c_2}\right\}\right\}$$