I solved the following heat equation PDE analytically by hand and also Maple the solutions were the same.
Also, I solved the PDE numerically using Maple. But the analytic solution and numerical solution plots are different with each other! Why?! And which one is correct?
For validating Maple's numerical solution, I solved the PDE using Mathematica (NDSolve) ,too and it gave me the same plot as Maple's numerical plot. \begin{equation}u_{t}-u_{xx}=0\end{equation}
\begin{equation}0<x<\pi\end{equation}
\begin{equation}t>0\end{equation}
Boundary Conditions:
\begin{cases}u(0,t)+u_{x}(0,t)=1\\u(\pi,t)+u_{x}(\pi,t)=-1\end{cases}
Initial Condition:
\begin{equation}u(x,0)=sin(x)\end{equation}
Maple analytic solution and code:
PDE3 := {u(0, t)+(D[1](u))(0, t) = 1, u(Pi, t)+(D[1](u))(Pi, t) = -1, diff(u(x, t), x$2) = diff(u(x, t), t), u(x, 0) = sin(x)};
sol3 := `assuming`([pdsolve(PDE3)], [0 < x and x < Pi, t > 0]);
plot3d(subs(infinity = 1000, rhs(sol3)), x = 0 .. Pi, t = 0 .. 0.5e-1);
Maple numerical code:
PDE4 := {diff(u(x, t), x$2) = diff(u(x, t), t)}
IBC := {u(0, t)+(D[1](u))(0, t) = 1, u(Pi, t)+(D[1](u))(Pi, t) = -1, u(x, 0) = sin(x)}
sol4 := pdsolve(PDE4, IBC, numeric)
plot3d(subs(infinity = 1000, rhs(sol3)), x = 0 .. Pi, t = 0 .. 0.5e-1)
Maple Analytic Solution Plot:
Maple Numerical Solution Plot:
Mathematica Numerical Solution Plot:








BoxRatios -> 1option to your Mathematica plot. – Edmund Jan 24 '19 at 01:00LaplaceTransformandeasyFourierTrigSeries, it's possible to show a correct series solution is $$e^{-t} \sin (x)-\frac{e^{-t}}{\pi }-\frac{e^t}{\pi }+\frac{4}{\pi } \left(\frac{\pi }{4}-\frac{x}{2}\right)+\frac{2}{\pi }-\frac{4}{\pi } \sum _{k}^{\infty } \left(\frac{e^{-4 k^2 t} (2 k \cos (2 k x)-\sin (2 k x))}{2 k \left(-1+4 k^2\right) \left(1+4 k^2\right)}+\frac{e^{-t} (-\cos (2 k x)+2 k \sin (2 k x))}{2 \left(-1+4 k^2\right)}+\frac{e^t (\cos (2 k x)+2 k \sin (2 k x))}{2 \left(1+4 k^2\right)}\right)$$ – xzczd Jan 24 '19 at 07:45