I would like to solve in Mathematica the well known inviscid Burgers' equation \begin{align} \begin{cases} u_t(x,t) + u(x,t)u_x(x,t)= 0 \\ u(x,0) = m(x) \end{cases} \end{align} where $$m(x) =\tanh(x+ m(x))$$ is given in implicit form. In particular, what I am looking for is to get a 3d plot of the pde and eventually the characteristic plot. Any idea how to approach the problem?

  • $\begingroup$ Welcome! Is this question about Mathematica or math in general? $\endgroup$
    – Yves Klett
    Jan 18 '15 at 13:42
  • $\begingroup$ the function $m(x)$ is defined in terms of itself? $\endgroup$
    – Nasser
    Jan 18 '15 at 14:12
  • $\begingroup$ Do you want a symbolic solution or a numeric approximation over some domain? $\endgroup$
    – Michael E2
    Jan 18 '15 at 14:13
  • $\begingroup$ @Nasser yes the function is given in such form. Michael, I just updated the question to make it more clear. $\endgroup$ Jan 18 '15 at 14:20

Define m in one of two ways:

m0 = NDSolveValue[{m[x] == Tanh[x + m[x]], s'[x] == 1, s[-1] == -1}, m, {x, -1, 0}]
m[x_] /; x < 0 := m0[x];
m[x_] /; x == 0 := x;
m[x_] /; x > 0 := -m0[-x];


Clear[m, m0];
m[x_?NumericQ] := m0 /. FindRoot[m0 == Tanh[x + m0], {m0, x}];

Then solve the PDE:

{sol} = NDSolve[{D[u[x, t], t] + u[x, t] D[u[x, t], x] == 0, u[x, 0] == m[x]},
  {x, -1, 1}, {t, 0, 1}]

There are some warnings:

NDSolve::mxsst: Using maximum number of grid points 10000 allowed by the MaxPoints or MinStepSize options for independent variable x. >>

NDSolve::bcart: Warning: an insufficient number of boundary conditions have been specified for the direction of independent variable x. Artificial boundary effects may be present in the solution. >>

The result looks ok, I think:

Plot3D[u[x, t] /. sol, {x, -1, 1}, {t, 0, 1}, AxesLabel -> Automatic]

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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