PDE with NDSolve gives solution despite not enough boundary conditions [duplicate]

This question already has an answer here:

For a given PDE, uniqueness of the solution requires boundary/initial conditions, the exact type of conditions depending on the particular PDE under consideration. For example consider the wave equation in 2 dimensions:

$u_{tt}(t,x)=c^2 u_{xx}(t,x)$

where $c>0$, we take $x\in[0,L]$ with $L>0$ and $t>0$. Then for instance we get a unique solution if we specify the functions $u(0,x)$, $u_t(0,x)$, $u(t,0)$ and $u(t,L)$ (with special care to choose these functions consistently). Mathematica behaves as expected in this case (i.e. it gives me a solution and no error/warnings).

However, if I don't specify part of the boundary conditions, say I don't fix the value of $u(t,L)$, then Mathematica gives no error (nor warning) and gives a solution for $u(t,x)$.

How is this possible? We don't expect such problems to have a unique solution, so is Mathematica implicitly choosing the missing boundary condition? Or is Mathematica using a property of numerical solutions to PDE that I am missing?

Examples:

With all the boundary conditions:

NDSolve[{
Derivative[2, 0][u][t, x] == 2 Derivative[0, 2][u][t, x],
u[0, x] == 0,
Derivative[1, 0][u][0, x] == 1,
u[t, 0] == Sin[t],
u[t, 5] == (1/3) Sin[3 t]},
u, {t, 0, 10}, {x, 0, 5}]

The same as above but with one boundary condition dropped:

NDSolve[{
Derivative[2, 0][u][t, x] == 2 Derivative[0, 2][u][t, x],
u[0, x] == 0,
Derivative[1, 0][u][0, x] == 1,
u[t, 0] == Sin[t]},
u, {t, 0, 10}, {x, 0, 5}]

marked as duplicate by zhk, m_goldberg, xzczd, happy fish, MarcoBMar 31 '17 at 7:24

• Please give the code for an example so that others can easily confirm what you are saying. – C. E. Mar 30 '17 at 14:29
• I'd be happy to, but copy/pasting Mathematica code in code environment gives the full input form which is hardly readable. How to proceed? – Bru Mar 30 '17 at 14:59
• Make the code as simple as possible (choose the most simple PDE etc., the wave equation should be fine) and then post that. We can demand nothing more. – C. E. Mar 30 '17 at 15:04
• The code is very simple. But it is the copy/paste procedure that produces extra things. I tried all the options for the copy command in Mathematica (copy as plain text, copy as input, ...) it always gives nasty things. For instance, ∂ gives PartialD and so on. – Bru Mar 30 '17 at 15:15
• The way to copy code properly is introduced in this post. Then, I should say I'm surprised that in this case the bcart warning doesn't pop up, I've included this in the previous question, thanks for pointing out. – xzczd Mar 31 '17 at 3:44

Comment

ClearAll["Global`*"];
c = 1;
pde = {D[u[t, x], t, t] == c^2 D[u[t, x], x, x]};

ics = {u[0, x] == 0, Derivative[1, 0][u][0, x] == 1};

bcs1 = {u[t, 0] == Sin[t], u[t, 5] == 1/3 Sin[3*t]};

bcAll1 = Flatten[{ics, bcs1}, 1];

sol1 = NDSolve[{pde, bcAll1}, {u}, {t, 0, 10}, {x, 0, 5}];

When you drop out one of the boundary condition, NDSolve artificially choose one for it. Now the real question is, what type of bc that could be? To this, I do not know the answer.

The same type of question has been asked here, but with no real answer.

You have left out this u[t, 5] == 1/3 Sin[3*t] and interestingly, NDSolve solve the pde without any warning, while making an artificial replacement for it.

bcs2 = {u[t, 0] == Sin[t]};

bcAll2 = Flatten[{ics, bcs2}, 1];

sol2 = NDSolve[{pde, bcAll2}, {u}, {t, 0, 10}, {x, 0, 5}];