# Specify direction of propagation in the 1-d wave equation in NSolve and NDSolve [duplicate]

I am solving the 1-d wave equation with the following initial conditions:

weqn = D[u[t, x], {t, 2}] == D[u[t, x], {x, 2}];
icn = {u[0, x] == Cos[x], Derivative[1, 0][u][0, x] == 0};
DSolveValue[{weqn, icn}, u[t, x], {t, x}]


The solution, as expected, is simply

1/2 (Cos[t - x] + Cos[t + x])


It is well known that these two solutions correspond to waves propagating to the right and to the left, respectively.

Now I want to solve the same equation with the same b.c.

tmin = 0; tmax = 10; xmin = -15; xmax = 15;
NDSolve[{weqn, icn}, u, {t, tmin, tmax}, {x, xmin, xmax}]


Mathematica solves the equation and gives the following warning

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


In this simple case, I know the analytical solution and can pick, say, the solution that represents the wave propagating to the right.

Is there any way to make Mathematica pick that particular solution?

• Use icn = {u[0, x] == Cos[x], Derivative[1, 0][u][0, x] == Sin[x]}; – LouisB May 9 '19 at 2:47
• For more information on how to model with the wave equation you can have a look at the (Finite Element Method) Acoustics in the Time Domain tutorial. The wave equation is one of the models presented there and many details about the equation and it's boundary conditions are presented. Hope this is useful. Search for Acoustics in the help system and the tutorial will come up. – user21 May 9 '19 at 4:09
• @LouisB thank you. – Thiago May 11 '19 at 1:01
• @user21 thank you, that was really helpful. – Thiago May 11 '19 at 1:01