# Issue in NDSolve

Why numericall solution is different than symbolic?

k = 5;

eq = {D[u[x, t], {x, 2}]*k == D[u[x, t], t], u[0, t] == 0,
u[1, t] == 0, u[x, 0] == x};

sol = NDSolve[eq, u, {x, 0, 1}, {t, 0, 10},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> "FiniteElement"}];

sol2 = u[x, t] /. First@DSolve[eq, u[x, t], {x, t}];

Plot[{u[x, t] /. sol /. x -> 1/2,
sol2 /. x -> 1/2 /. {Infinity -> 100} // Activate}, {t, 0, 10},
PlotRange -> All, PlotLegends -> {"Numeric", "Symbolic"}] • Related: mathematica.stackexchange.com/a/127411/1871 So an old-fashined way to fix the problem is to set Method -> {"MethodOfLines", "DifferentiateBoundaryConditions" -> {True, "ScaleFactor" -> 100}}, but I'm not sure about how to fix it when "FiniteElement" is chosen. (I should say the result is somewhat surprising, according to this answer "FiniteElement" seems to be free from this problem. ) Jun 19 '17 at 10:54
• @xzczd.Thanks.1 for good comment. Jun 19 '17 at 20:19

eq = {D[u[x, t], {x, 2}]*k == D[u[x, t], t], u[0, t] == 0, 