# Solving PDE numerically; getting error NDSolve::ndnco

I'm attempting to solve a PDE with initial and boundary conditions numerically, but my code produces a message saying I have an insufficient number of initial conditions. This is indeed false, as I can even solve the PDE with these conditions analytically. The code I'm using is,

Clear[nsol];
Clear[t];
nsol =
NDSolve[
{D[u[x, t], {x, 2}] == D[u[x, t], {t, 2}],
u[x, 0] == x*E^(-x^2),
Derivative[0, 1][u][x, 0] == 0,
u[0, t] == 0},
u, {x, -10, 10}, {t, 0, 12}]


My code is posted in a screenshot below. If anyone can help that'd be great! :) • Your conditions could be u[x, 0] == x*E^(-x^2), Derivative[0, 1][u][x, 0] == 0, u[-10, t] == u[10, t] == 0 – user36273 Sep 28 '16 at 13:11
• Hey thanks for the comment! That doesn't seem to provide a solution either, and I think those boundary conditions may affect my solution if it were to work otherwise. – charl1e Sep 28 '16 at 13:23

For a numerical solution you have to add a boundary condition. Now with DSolveValue we get:

sol = DSolveValue[{D[u[x, t], {x, 2}] == D[u[x, t], {t, 2}],
u[x, 0] == x*E^(-x^2), Derivative[0, 1][u][x, 0] == 0,
u[0, t] == 0},
u, {x, -10, 10}, {t, 0, 12}] Plot3D[sol[x, t], {x, 0, 10}, {t, 0, 12}, PlotRange -> All, AxesLabel -> Automatic] With a second boundary condition we get;

nsol = NDSolve[{D[u[x, t], {x, 2}] == D[u[x, t], {t, 2}],
u[x, 0] == x*E^(-x^2), Derivative[0, 1][u][x, 0] == 0,
u[0, t] == u[10, t] == 0},
u, {x, 0, 10}, {t, 0, 12}];

Plot3D[u[x, t] /. nsol, {x, 0, 10}, {t, 0, 12}, PlotRange -> All,
AxesLabel -> Automatic] • Thanks so much for helping out! It's very much appreciated, I'm also very thankful that you showed how to get the analytical solution too. Thanks so much for your time :) – charl1e Sep 29 '16 at 1:10