# NDSolve computes wrong solution?

Please excuse me if the question has already been answered somewhere else, but I was not able to find it. Could somebody tell me what I am doing wrong here? The solution of DSolve is of course correct (u[t,x] = 5tx, u[1,10]/.sol = 50), but the one of NDSolve is going in the complete wrong direction (u[1,10]/.soln = -50). Why??? Do you get the same values when you run the code? Where did I write something wrong? This is really driving me nuts!

sol = DSolve[
{
0 + D[u[t, x], {x, 2}] == 0
, u[t, 0] == 0
, (D[u[t, x], x] /. x -> 10) == 5*t
}
, {u}
, {t, x}
][];
u[1, 10] /. sol
(*50*)

soln = NDSolve[
{
0 + D[u[t, x], {x, 2}] == 0
, u[t, 0] == 0
, (D[u[t, x], x] /. x -> 10) == 5*t
}
, {u}
, {t, 0, 1}
, {x, 0, 10}
][];
u[1, 10] /. soln
(*-50*)

• I get the same result, looks like a bug to me, most probably in the relatively new FE code. It is just a suscpicion, but Method->"MethodOfLines" complains that it can't handle that case of boundary conditions (which I think is also reasonable) which only leaves Method->"FiniteElement". I'd report it to WRI. Probably just a simple sign problem as you can get what looks like the desired result when switching the sign in the boundary condition to -5*t :-) – Albert Retey May 11 '15 at 20:29
• Looks like a bug to me too, but I'll let someone more knowledgeable confirm it. – Daniel Lichtblau May 11 '15 at 23:36
• Plots of the two solutions in the Question clearly indicate the NSolve is returning 5 t x, and NDSolve is returning the numerical representation of -5 t x. Curiously, DSolveValue[{0 + D[u[t, x], {x, 2}] == 0, u[t, 0] == 0, (D[u[t, x], x] /. x -> 10) == 5*t}, {u}, {t, x}] under Mathematica 10.1 returns unevaluated. – bbgodfrey May 12 '15 at 0:48
• By the way, one can work around this in NDSolve by making it into an explicit ODE. soln2[t_?NumericQ] := NDSolve[{D[u[x], {x, 2}] == 0, u == 0, (D[u[x], x] /. x -> 10) == 5*t}, {u}, {x, 0, 10}]. My suspicion is that NDSolve is confusing itself in trying to handle an apparent PDE what really is only a DE in one variable. That's just a guess though. – Daniel Lichtblau May 13 '15 at 16:14
• This problem still persists as of Version 10.1 – gwr May 20 '15 at 9:45

This is a NeumannValue and this can very subtle. There is a section NeumannValue and Formal Partial Differential Equations that tries to explain it.
soln = NDSolve[{D[u[t, x], {x, 2}] + NeumannValue[5 t, x == 10] == 0,
50.00000000002088
`