Skip to main content
added assumptions
Source Link
Nasser
  • 150.2k
  • 12
  • 161
  • 374

This could possibly be duplicate. I do not know. Hard to search. But I just found out that for a very simple heat PDE in 1D with homogeneous boundary conditions, DSolve gives answer which does not make sense to me. It gives zero as the solution.

Here are the specs

\begin{align*} \frac{\partial u}{\partial t} & =k\frac{\partial^{2}u}{\partial t^{2}}\\ t & >0\\ 0 & <x<L \end{align*}

Initial conditions

$$ u\left( x,0\right) =\sin\left( \pi\frac{x}{L}\right) $$

BC

\begin{align*} u\left( 0,t\right) & =0\\ u\left( L,t\right) & =0 \end{align*}

Here is the Mathematica code to solve it using DSolve

ClearAll[x,t,L0,k]
eq=D[u[x,t],{x,2}]*k==D[u[x,t],t];
bc={u[0,t]==0,u[L0,t]==0};
ic=u[x,0]==Sin[Pi x/L0 ]; 

(*now tried with assumptions and no assumptions, same result*)

(*sol=DSolve[{eq,ic,bc},u[x,t],{x,t}]*)
sol=DSolve[{eq, ic, bc}, u[x, t],{x, t},Assumptions->{L0 > 0,t >= 0,x >= 0}]

Here is Mathematica answer

Mathematica graphics

There is no inconsistency in boundary and initial conditions.

But this can be easily solved by hand. The analytical solution is

$$ u\left( x,t\right) =\sin\left( \frac{\pi}{L}x\right) e^{-k\left( \frac{\pi}{L}\right) ^{2}t}% $$

NDSolve solves this correctly. Here is side-by-side of the solution by NDSolve and the above analytical solution to verify that the above analytical solution is correct.

values={k->2/3,L0->2}; 
numericalSol=NDSolve[Evaluate[{eq,ic,bc}/.values],u,{x,0,2},{t,0,3}];
myAnalyticalSolution[x_,t_]:= (Sin[ Pi/L0 x] Exp[-k ( Pi/L0)^2 t])/.values;

Manipulate[
 Grid[{{Plot[u[x, t] /. numericalSol, {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "NDSolve", 
     ImageSize -> 250], 
    Plot[myAnalyticalSolution[x, t], {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "analytical", 
     ImageSize -> 250]}}],
 {t, 0, 3, .01}]

enter image description here

Question is Why did DSolve gives zero as solution? And is there a way to correct this at user level (may be using some option or such).

Is this a bug in DSolve?

Using Version 11.1.1 on windows 7.

Mathematica graphics

This could possibly be duplicate. I do not know. Hard to search. But I just found out that for a very simple heat PDE in 1D with homogeneous boundary conditions, DSolve gives answer which does not make sense to me. It gives zero as the solution.

Here are the specs

\begin{align*} \frac{\partial u}{\partial t} & =k\frac{\partial^{2}u}{\partial t^{2}}\\ t & >0\\ 0 & <x<L \end{align*}

Initial conditions

$$ u\left( x,0\right) =\sin\left( \pi\frac{x}{L}\right) $$

BC

\begin{align*} u\left( 0,t\right) & =0\\ u\left( L,t\right) & =0 \end{align*}

Here is the Mathematica code to solve it using DSolve

ClearAll[x,t,L0,k]
eq=D[u[x,t],{x,2}]*k==D[u[x,t],t];
bc={u[0,t]==0,u[L0,t]==0};
ic=u[x,0]==Sin[Pi x/L0 ];
sol=DSolve[{eq,ic,bc},u[x,t],{x,t}]

Here is Mathematica answer

Mathematica graphics

There is no inconsistency in boundary and initial conditions.

But this can be easily solved by hand. The analytical solution is

$$ u\left( x,t\right) =\sin\left( \frac{\pi}{L}x\right) e^{-k\left( \frac{\pi}{L}\right) ^{2}t}% $$

NDSolve solves this correctly. Here is side-by-side of the solution by NDSolve and the above analytical solution to verify that the above analytical solution is correct.

values={k->2/3,L0->2}; 
numericalSol=NDSolve[Evaluate[{eq,ic,bc}/.values],u,{x,0,2},{t,0,3}];
myAnalyticalSolution[x_,t_]:= (Sin[ Pi/L0 x] Exp[-k ( Pi/L0)^2 t])/.values;

Manipulate[
 Grid[{{Plot[u[x, t] /. numericalSol, {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "NDSolve", 
     ImageSize -> 250], 
    Plot[myAnalyticalSolution[x, t], {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "analytical", 
     ImageSize -> 250]}}],
 {t, 0, 3, .01}]

enter image description here

Question is Why did DSolve gives zero as solution? And is there a way to correct this at user level (may be using some option or such).

Is this a bug in DSolve?

Using Version 11.1.1 on windows 7.

Mathematica graphics

This could possibly be duplicate. I do not know. Hard to search. But I just found out that for a very simple heat PDE in 1D with homogeneous boundary conditions, DSolve gives answer which does not make sense to me. It gives zero as the solution.

Here are the specs

\begin{align*} \frac{\partial u}{\partial t} & =k\frac{\partial^{2}u}{\partial t^{2}}\\ t & >0\\ 0 & <x<L \end{align*}

Initial conditions

$$ u\left( x,0\right) =\sin\left( \pi\frac{x}{L}\right) $$

BC

\begin{align*} u\left( 0,t\right) & =0\\ u\left( L,t\right) & =0 \end{align*}

Here is the Mathematica code to solve it using DSolve

ClearAll[x,t,L0,k]
eq=D[u[x,t],{x,2}]*k==D[u[x,t],t];
bc={u[0,t]==0,u[L0,t]==0};
ic=u[x,0]==Sin[Pi x/L0 ]; 

(*now tried with assumptions and no assumptions, same result*)

(*sol=DSolve[{eq,ic,bc},u[x,t],{x,t}]*)
sol=DSolve[{eq, ic, bc}, u[x, t],{x, t},Assumptions->{L0 > 0,t >= 0,x >= 0}]

Here is Mathematica answer

Mathematica graphics

There is no inconsistency in boundary and initial conditions.

But this can be easily solved by hand. The analytical solution is

$$ u\left( x,t\right) =\sin\left( \frac{\pi}{L}x\right) e^{-k\left( \frac{\pi}{L}\right) ^{2}t}% $$

NDSolve solves this correctly. Here is side-by-side of the solution by NDSolve and the above analytical solution to verify that the above analytical solution is correct.

values={k->2/3,L0->2}; 
numericalSol=NDSolve[Evaluate[{eq,ic,bc}/.values],u,{x,0,2},{t,0,3}];
myAnalyticalSolution[x_,t_]:= (Sin[ Pi/L0 x] Exp[-k ( Pi/L0)^2 t])/.values;

Manipulate[
 Grid[{{Plot[u[x, t] /. numericalSol, {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "NDSolve", 
     ImageSize -> 250], 
    Plot[myAnalyticalSolution[x, t], {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "analytical", 
     ImageSize -> 250]}}],
 {t, 0, 3, .01}]

enter image description here

Question is Why did DSolve gives zero as solution? And is there a way to correct this at user level (may be using some option or such).

Is this a bug in DSolve?

Using Version 11.1.1 on windows 7.

Mathematica graphics

Tweeted twitter.com/StackMma/status/877104825850355712
Source Link
Nasser
  • 150.2k
  • 12
  • 161
  • 374

Mathematica DSolve gives zero solution for 1D heat PDE

This could possibly be duplicate. I do not know. Hard to search. But I just found out that for a very simple heat PDE in 1D with homogeneous boundary conditions, DSolve gives answer which does not make sense to me. It gives zero as the solution.

Here are the specs

\begin{align*} \frac{\partial u}{\partial t} & =k\frac{\partial^{2}u}{\partial t^{2}}\\ t & >0\\ 0 & <x<L \end{align*}

Initial conditions

$$ u\left( x,0\right) =\sin\left( \pi\frac{x}{L}\right) $$

BC

\begin{align*} u\left( 0,t\right) & =0\\ u\left( L,t\right) & =0 \end{align*}

Here is the Mathematica code to solve it using DSolve

ClearAll[x,t,L0,k]
eq=D[u[x,t],{x,2}]*k==D[u[x,t],t];
bc={u[0,t]==0,u[L0,t]==0};
ic=u[x,0]==Sin[Pi x/L0 ];
sol=DSolve[{eq,ic,bc},u[x,t],{x,t}]

Here is Mathematica answer

Mathematica graphics

There is no inconsistency in boundary and initial conditions.

But this can be easily solved by hand. The analytical solution is

$$ u\left( x,t\right) =\sin\left( \frac{\pi}{L}x\right) e^{-k\left( \frac{\pi}{L}\right) ^{2}t}% $$

NDSolve solves this correctly. Here is side-by-side of the solution by NDSolve and the above analytical solution to verify that the above analytical solution is correct.

values={k->2/3,L0->2}; 
numericalSol=NDSolve[Evaluate[{eq,ic,bc}/.values],u,{x,0,2},{t,0,3}];
myAnalyticalSolution[x_,t_]:= (Sin[ Pi/L0 x] Exp[-k ( Pi/L0)^2 t])/.values;

Manipulate[
 Grid[{{Plot[u[x, t] /. numericalSol, {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "NDSolve", 
     ImageSize -> 250], 
    Plot[myAnalyticalSolution[x, t], {x, 0, 2}, 
     PlotRange -> {{0, 2}, {-.1, 1}}, PlotLabel -> "analytical", 
     ImageSize -> 250]}}],
 {t, 0, 3, .01}]

enter image description here

Question is Why did DSolve gives zero as solution? And is there a way to correct this at user level (may be using some option or such).

Is this a bug in DSolve?

Using Version 11.1.1 on windows 7.

Mathematica graphics