1
$\begingroup$

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);

enter image description here

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:

enter image description here

Maple Numerical Solution Plot:

enter image description here

Mathematica Numerical Solution Plot:

enter image description here

$\endgroup$

closed as off-topic by Chris K, Nasser, m_goldberg, xzczd, march Jan 24 at 6:53

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Add Wolfram code for your Mathematica plot. At first glance it seems you just need to add the BoxRatios -> 1 option to your Mathematica plot. $\endgroup$ – Edmund Jan 24 at 1:00
  • $\begingroup$ @Edmund There is no problem with Mathematica's plot that's just for validating the Maple's numerical solution. The Mathematica's plot validates the numerical solution plot of Maple. The problem is: Why numerical and analytical plots are different? $\endgroup$ – Moreza7 Jan 24 at 1:13
  • $\begingroup$ Since 2 out of 3 approaches agree, I'd guess the Maple analytical solution is wrong :) Actual evidence: it doesn't look like the Maple analytical solution matches the initial conditions. $\endgroup$ – Chris K Jan 24 at 2:01
  • 5
    $\begingroup$ I'm voting to close this question as off-topic because it's more of a Maple question than a Mathematica question. $\endgroup$ – Chris K Jan 24 at 3:35
  • 1
    $\begingroup$ Side note: With the help of LaplaceTransform and easyFourierTrigSeries, 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)$$ $\endgroup$ – xzczd Jan 24 at 7:45
4
$\begingroup$

Maple analytical solution appears to be wrong. It does not even satisfy the initial conditions. Mathematica currently can not solve this PDE analytically (but this is better than solving it and giving wrong solution ;)

Here is side by side animation of Maple solution and Mathematica animated for one second.

Maple

restart;
PDE3 := diff(u(x, t), x$2) = diff(u(x, t), t):
ic:= u(x, 0) = sin(x):
bc:= u(0, t)+(D[1](u))(0, t) = 1, u(Pi, t)+(D[1](u))(Pi, t) = -1:
sol3 := pdsolve([PDE3,ic,bc],u(x,t)):
sol:=subs(infinity=20,rhs(sol3)):
plots:-animate(plot,[sol,x=0..Pi],t=0..1,frames=100)

Mathematica graphics

Mathematica

ClearAll[u,x,t];
pde=D[u[x,t],t]==D[u[x,t],{x,2}];
ic=u[x,0]==Sin[x];
bc={u[0,t]+Derivative[1,0][u][0,t]==1, u[Pi,t]+Derivative[1,0][u][Pi,t]==-1};
sol=NDSolve[{pde,ic,bc},u,{x,0,Pi},{t,0,1}]


Manipulate[
Grid[{{Row[{"t=",t}]},
{Plot[Evaluate[u[x,t]/.sol],{x,0,Pi},
 PlotRange->{{0,Pi},{-1,1}},ImageSize->300,
 Ticks->{{0,Pi/4,Pi/2,3/4 Pi,Pi},Automatic}]
}}],
{{t,0,"time"},0,1,.01,Appearance->"Labeled"}
]

Mathematica graphics

Animation

Maple

enter image description here

Mathematica

enter image description here

May be you can report this bug to Maplesoft.

$\endgroup$
  • $\begingroup$ Thank You! I posted a new question which shows my analytic solution of the problem which is not compatible with Mathematica's numerical solution again. Would you please look at that? mathematica.stackexchange.com/questions/190169/… $\endgroup$ – Moreza7 Jan 24 at 12:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.