What boundary is added when boundary condition is not sufficient?

When insufficient boundary conditions are given to NDSolve for solving PDE, usually the warning NDSolve::bcart pops up:

sol = u /. NDSolve[{D[u[t, x], t] == D[u[t, x], x, x],
u[0, x] == Exp[-x^2],
Derivative[0, 1][u][t, -1] == 2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]];


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

However, NDSolve still gives an answer in this case:

Manipulate[Plot[sol[t, x], {x, -1, 1}, PlotRange -> {-2, 2}], {t, 0, 2}]


I wonder what boundary has been introduced for this solution?

sol is changeless no matter how many times you rerun the code, so there exists a certain strategy, which I fail to find in the documentation. The only thing I know is that NDSolve doesn't use the value of the initial condition at the end point:

sol2 = u /.
NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == Exp[-x^2],
Derivative[0, 1][u][t, -1] == 2/E,
u[t, 1] == Exp[-1]},
u, {t, 0, 2}, {x, -1, 1}][[1]]

Manipulate[Plot[sol2[t, x], {x, -1, 1}, PlotRange -> {-2, 2}], {t, 0, 2}]


or the derivative value of the initial condition at the end point:

sol3 = u /.
NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == Exp[-x^2],
Derivative[0, 1][u][t, -1] == 2/E,
Derivative[0, 1][u][t, 1] == -2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]]

Manipulate[Plot[sol3[t, x], {x, -1, 1}, PlotRange -> {-2, 2}], {t, 0, 2}]


Well, I know the best countermeasure is to add the missing boundary condition, I'm just curious. Anyway, if the output with insufficient boundary condition is completely meaningless, why doesn't NDSolve simply stop calculating and return the input?

Finally, as mentioned by Bru, the warning bcart doesn't always pop up, for example:

sol = u /. NDSolve[{D[u[t, x], t, t] == D[u[t, x], x, x],
u[0, x] == Exp[-x^2],
Derivative[1, 0][u][0, x] == 0,
Derivative[0, 1][u][t, -1] == 2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]];


Update

I've partly found the answer, in short, NDSolve doesn't intentionally add any boundary condtion in this case, the solution we get is just a outgrowth of one-sided formula. Sadly I still don't know what's the equivalent boundary condition to this outgrowth. I tried to ask it in scicomp.SE, but the result is… not great. Please check the following post for more information:

Why do I still obtain a unique solution with one-sided formula when b.c. isn't enough?

Remark

In the examples above, TensorProductGrid sub-method has been automatically chosen for spatial discretization, and TensorProductGrid is the only available method for spatial discretization in and before v9.

Since v10, FiniteElement method is implemented in NDSolve. Unlike TensorProductGrid, the b.c. added by FiniteElement is documented. As mentioned in the Details of NeumannValue:

…not specifying a boundary condition at all is equivalent to specifying a Neumann 0 condition.

Notice FiniteElement method will only be triggered under certain condition. See the following post for more information:

PDEs : automatic method choice : TensorProductGrid or FiniteElement?

2 Answers

You may try to fit a boundary condition, although it won't give you hints about the inner workings:

sol = u /. NDSolve[{ D[u[t, x], t] == D[u[t, x], x, x],
u[0, x] == Exp[-x^2],
Derivative[0, 1][u][t, -1] == 2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]]

n = 30;
coefs = Table[c[i], {i, n}];
solMy = u /. NDSolve[{
D[u[t, x], t] == D[u[t, x], x, x],
u[0, x] == Exp[-x^2],
u[t, 1] == NonlinearModelFit[Table[{t, sol[t, 1]}, {t, 0, 2, .00005}],
coefs.Array[t^# &, n] + Exp[-1], coefs, t]["BestFit"],
Derivative[0, 1][u][t, -1] == 2/E},
u, {t, 0, 2}, {x, -1, 1}][[1]]

Plot3D[Abs[solMy[t, x] - sol[t, x]], {x, -1, 1}, {t, 0, 2}, PlotRange -> All]


• You mixed up -1 and 1 in your code, right? – xzczd Feb 21 '15 at 2:13
• @xzczd Yep, I tried both and ended up mixing them. I'll edit in a few minutes. Thanks for checking. – Dr. belisarius Feb 21 '15 at 2:25
• 千金市骨 :) Hope someone can answer this question one day. – xzczd Feb 27 '15 at 16:26

Well I think that a possible answer is that the b.c. is simply the one that occurs. It is not of the form $$w_b=const$$ but of the time-dependant form $$w_b=w_b(t)$$. There may not be an analytic expression for $$w_b(t)$$ as it could be the solution of a differential equation that cannot be solved analytically. So why don't check whether $$w_b(t)$$ is just the solution of the differential equation in your question?

I think this is also the answer to a question of mine. Check this post.

• "So why don't check… " The solution is valid of course. This can be easily checked with Plot3D[D[u[t, x], t] - D[u[t, x], x, x] /. u -> sol // Evaluate, {t, 0, 1/2}, {x, -1, 1}(*, PlotRange -> All]*), one will see the error gets smaller when spatial grid gets denser (this can be adjusted with {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> 25(*adjust this*), "MinPoints" -> 25(*adjust this*), "DifferenceOrder" -> 4}}). – xzczd Dec 26 '18 at 14:39
• Then the problem is solved! The solution that occurs is characterised by time-dependent b.c. that is the numerical solution of the equation in question. It sounds reasonable. However if I am missing something let me know. – dkstack Dec 26 '18 at 14:44
• Indeed, this is an answer, but I should say it's a trivial one and my problem isn't solved with satisfaction. A fatal truth is, nobody has ever managed to figure out the physical meaning of this type of solution. – xzczd Dec 26 '18 at 14:53
• I think that it is neither trivial nor artificial. It is just a solution with its own b.c. like anyother solution. What kind of b.c.? Time dependent without analytical expression, solutions of the PDE system in question. Why should such a solution be termed trivial? Probably we should post a question concerning b.c. without explicit analytical expression. This would probably clarify our discussion – dkstack Dec 26 '18 at 16:04
• Well, I use the word trivial because I think the explanation in your answer is something that, frankly speaking, anybody that has read through my question will immediately notice. And this has essentially been included in the answer posted by belisarius. However, what I'm concerned is something deeper. Can this b.c. been expressed in simpler, or analytic form? Does this solution own physical meaning in some cases? Why doesn't NDSolve simply stop calculating? These all remain unclear. – xzczd Dec 26 '18 at 16:28