I am wondering what is the best way to solve numerically a initial-boundary value problem of heat equation like this (surely I've made a lot of mistakes in the code):
NDSolve[{4 D[T[x, t], t] == D[T[x, t], x, x] , T[x, -Infinity] == 0, T[Infinity, t] == 0, -Derivative[1, 0][T][0, t] == 2 Sqrt[Pi] Exp[-(t^2/2)] }, T, {x, 0, 5}, {t, 0, 5}] As we can see, there's one i.c. at $-\infty$:
T[x, -Infinity] == 0 one b.c. at $x=\infty$:
T[Infinity, t] == 0 and one b.c. as the derivative of the unknown with respect to $x$ at $x=0$ equal to the function $\exp(-t^2/2)$ (i.e. $-\left.\frac{\partial T}{\partial x}\right|_{x=0}=2\sqrt{\pi} \exp(-t^2/2)$)
-Derivative[1, 0][T][0, t] == 2 Sqrt[Pi] Exp[-(t^2/2)] The analytical solution is:
T[x_, t_] := NIntegrate[ 1/Sqrt[τ] Exp[-((t - τ)^2/2)] Exp[-(x^2/τ)], {τ, 0, Infinity}] Just to check the solution:
With[{trange = {-2, 0.5, 3}}, Show[{ListPlot[ Table[{x, NIntegrate[ 1/Sqrt[τ] Exp[-((t - τ)^2/ 2)] Exp[-(x^2/τ)], {τ, 0, Infinity}]}, {t, trange}, {x, 0, 4, 0.05}], PlotLegends -> {"t = -2", "t = 0.5", "t = 3"}], Table[Plot[ NIntegrate[ 1/Sqrt[τ] Exp[-((t - τ)^2/ 2)] Exp[-(0^2/τ)], {τ, 0, Infinity}] - 2 Sqrt[Pi] Exp[-(t^2/2)] x, {x, 0, 0.7}], {t, trange}]}, Frame -> True, PlotRange -> All, FrameLabel -> {x, "T[x,t]"}]] Thanks in advance.




T[x, -Infinity] == 0. Thanks. $\endgroup$T[x, -Infinity] == 0can be interpreted as an initial condition. The BCs areT[Infinity,t] == 0and the condition on the derivative:-Derivative[1, 0][T][0, t] == 2 Sqrt[Pi] Exp[-(t^2/2)]. Thanks. $\endgroup$NIntegrate[(Exp[(-(1/2)) (t - \[Tau])^2] Exp[-(x^2/\[Tau])])/ Sqrt[\[Tau]] /. t -> 1 /. x -> 1, {\[Tau], 0, Infinity}] - Sum[((-1)^n 2^(-1 - n) E^(-(t^2/2)) t^m x^( 4 n) ((2^(1/4 + m/2) Gamma[3/4 - m/2] Gamma[1/4 + m/2])/( Gamma[3/4 - m/2 + n] Gamma[1 + 2 n]) + x ((2^(-(1/4) + m/2) x Gamma[1/4 - m/2] Gamma[3/4 + m/2])/( Gamma[5/4 - m/2 + n] Gamma[2 + 2 n]) - ( 2 x^(2 m) Gamma[1/2 - m] Gamma[1/2 + m])/( Gamma[1 + n] Gamma[3/2 + m + 2 n]))))/Gamma[1 + m] /. t -> 1 /. x -> 1, {n, 0, 20}, {m, 0, 20}]$\endgroup$