4
$\begingroup$

How to use NDSolve to solve 1+1 D heat equation $u_t=u_{xx}$ with $ -\infty<x<\infty$ and $0\leq t\leq T$?

NDSolve[{Derivative[1, 0][u][t, x] == Derivative[0, 2][u][ t, x], 
u[0, x] == Sin[x]}, u, {t, 0, 10}, {x, -Infinity, Infinity}]

The error code is: NDSolve::ndnl: Endpoint -∞ in {x, -∞, ∞} is not a real number.

$\endgroup$

1 Answer 1

3
$\begingroup$
How to use NDSolve to solve 1+1 D heat equation ut=uxx with −∞<x<∞ and 0≤t≤T?

For infinite spatial domain, do not give boundary conditions. No need for numerical solution, since exact solution exist

ClearAll["Global`*"];
pde = D[u[x, t], t] == D[u[x, t], {x, 2}];
ic = u[x, 0] == Sin[x];
sol = DSolve[{pde, ic}, u[x, t], {x, t}, Assumptions -> t > 0]

$$ \left\{\left\{u(x,t)\to e^{-t} \sin (x)\right\}\right\} $$

Now you have solution for all time. You can plot it for any period you want.

$\endgroup$
3
  • $\begingroup$ Thanks for the answer. But the pde I really want to solve is a nonlinear pde. DSolve can not solve it analytically. I was thinking to solve it numerically using NDSolve. The ranges are the same: $x\in (-\infty,\infty), t\in[0,10])$. $\endgroup$
    – mike
    Commented Apr 14, 2020 at 4:14
  • 1
    $\begingroup$ @mike then you could post separate question on that, but it will be better to use the PDE you actually want solved and not another one to reduce confusion. $\endgroup$
    – Nasser
    Commented Apr 14, 2020 at 6:03
  • 2
    $\begingroup$ @mike You can only have numerical solution for finite numbers, you can't have numerical solution with infinities. $\endgroup$
    – m0nhawk
    Commented Apr 14, 2020 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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