# Heat Equation with Mathematica Neumann / Dirichlet Conditions

This is the question I am trying to solve

After fours hours of research and 61 attempts (just today) on how to do this, I'm asking for help. I've been in hospital and am now trying to catch up on lectures and unfortunately, although the Maths makes sense, the Mathematica does not.

This is the latest attempt and I really cannot find where I am going wrong.

NDSolve[{D[T[x, t], t] == 2.5*D[T[x, t], {x, 2}] + 10*Exp[-x^2],T[-2, t] == 22, (D[T[x, t], x] /. x -> 2) == 0}, T[x, t], {x, -2, 2}, {t, 0, 20}]


I am literally in tears typing this because I don't know what do anymore.

This is what it appears as in Mathematica

I assumed because I am given the flux, this is Neumann boundary conditions but the error is coming up about Dirichlet boundary conditions. What am I doing wrong and how do I go about fixing it?

• If I add the initial condition then it works for me. I don't know what the second error message is complaining about, but I think the solution looks correct once I do that. Commented Jan 11, 2019 at 11:39
• Yeah, I made the same observation. The error messages are really misleading. Commented Jan 11, 2019 at 11:44
• @KraZug Thank you! Commented Jan 11, 2019 at 11:57
• @HenrikSchumacher Thank you! Commented Jan 11, 2019 at 11:57
• why does the problem says the heat is open to flow through the right boundary then it says the flux is zero? flux zero means it is insulated on the right. If something is insulated, does this not mean heat does not flow? which book/page number did you get this problem from? Commented Jan 11, 2019 at 14:41

Everything works fine if you include the initial condition,

alpha = 2.5;

HE = D[T[x, t], t] == alpha*D[T[x, t], {x, 2}] + 10*Exp[-x^2]

sol = NDSolve[{HE, T[x, 0] == 22, T[-2, t] == 22, (D[T[x, t], x] /. x -> 2) == 0},
T, {x, -2, 2}, {t, 0, 20}]

• Thank you, ever so much! Commented Jan 11, 2019 at 11:56
• @Grace My pleasure :)
– zhk
Commented Jan 11, 2019 at 11:56