4

Now I'm interested in the equation $$\frac{\partial }{\partial x}\Bigl(\text{sgn}(x) u \Big) +\frac{\partial}{\partial x} \Bigl[ u^2 \frac{\partial u}{\partial x} \Bigr] =0$$ with boundary conditions $u(-5)=u(5)=0$

Since $\text{sgn}(x)$ is not differentiable at $x=0$, I expectd ND solve to have some problems. I tried

sol = NDSolveValue[{
  0 == D[Sign[x]*u[x],x] + D[u[x]^2 D[u[x], x], x],
   u[-6] == 0, u[6] == 0}
  , u, {x, -7, 7}]

but I can't even plot it and I think that I'm writing it in the wrong way. Could someone confirm I wrote the right snippet and show the plot I should obtain?

  • I asked a related question three days ago, where the equation was the PDE $\partial_t u = \partial_x (\text{sign}(x) u) + \partial_x (u^2\partial_x u)$. The one I have above it's the steady state solution, and I want to compute it directly, instead of integrating in time.
Vefhug
  • 421
  • 2
  • 9
  • "but I can't even plot it " If you can't even solve it, you won't be able to plot it of course. – xzczd Sep 22 '20 at 12:52
  • @xzczd yes, but I think it's a problem of my code/Mathematica in my laptop. So I need to see at least what I should obtain – Vefhug Sep 22 '20 at 12:57
  • Actually, one of my concerns is also if the problem is ill-posed. Because this could be the source of my problem. Do you obtain something reasonable with NDsolve? @xzczd – Vefhug Sep 22 '20 at 13:14
  • Is u[x]==u[-x] symmetric? – Ulrich Neumann Sep 22 '20 at 13:16
  • @UlrichNeumann I don't know honestly... from a picture in the linked question it seems so. Dooes your NDsolve obtain something reasonable? – Vefhug Sep 22 '20 at 13:17
  • @Vefhug If yes u[x]==const would solve the ode! – Ulrich Neumann Sep 22 '20 at 13:19
  • Yes, $u(x)=0$ would be a solution. But if instead of $u^2$ there would be $\sqrt{u}$, then it seems (see figure at the end of the xzczd's post here https://mathematica.stackexchange.com/questions/230429/nonlinear-dispersal-equation-modeling-insect-aggregation?noredirect=1&lq=1 ) that there's a not trivial solution, right? @UlrichNeumann – Vefhug Sep 22 '20 at 13:21
  • I'm talking about $$\partial_x (\text{sign}(x) u) + \partial_x ( \sqrt{u} \partial_x u)$$ with homogeneous b.c.'s as before – Vefhug Sep 22 '20 at 13:23
  • The problematic part is: D[Sign[x]*u[x],x]. You can not take the derivative of "Sign" in the normal sense. It would result in a distribution, the DiracDelta. But this makes only sense inside an integral. – Daniel Huber Sep 22 '20 at 13:27
  • @DanielHuber yes, indeed I wrote a Python code following a finite element approach, (I'm newbie at Mathematica) and solving the resulting non-linear system with fixed-point iterations, but the solution explodes. I was thinking to show the steps I did, but since it's a Mathematica site, I don't know if it makes sense to show it honestly. – Vefhug Sep 22 '20 at 13:32
  • For instance, what is the output you obtain using a finite element method with Mathematica? @DanielHuber – Vefhug Sep 22 '20 at 14:04

1 Answers1

9

The problem can be solved analytically.

First we transform the equation a bit. Integrate the ODE once we obtain

neweq = Integrate[D[Sign[x] u[x], x] + D[u[x]^2 D[u[x], x], x], x] == c
(* Sign[x] u[x] + u[x]^2 Derivative[1][u][x] == c *)

Then it's not hard to notice Sign[x] u[x] + u[x]^2 Derivative[1][u][x] is an odd function. We can analyze it manually, but here I'll use DChange to make the post a bit more interesting:

(* Definition of DChange isn't included in this post,
   please find it in the link above. *)
DChange[Sign[x] u[x] + u[x]^2 u'[x], x == -X, x, X, u[x]] // Expand
(* -Sign[X] u[X] - u[X]^2 Derivative[1][u][X] *)

Thus Sign[x] u[x] + u[x]^2 u'[x] == 0 at x == 0. Since c is a constant, we conclude c == 0.

Next we write it as an ODE of $x(u)$ for convenience of subsequent discussion:

neweqreverse = neweq /. c -> 0 /. {u[x] -> u, x -> x[u], u'[x] -> 1/x'[u]}
(* u Sign[x[u]] + u^2/Derivative[1][x][u] == 0 *)

Solve the ODE for $x>0$ and $x<0$ separately:

{eqR, eqL} = Simplify[neweqreverse, #] & /@ {x[u] > 0, x[u] < 0}
(* {u + u^2/Derivative[1][x][u] == 0, u (-1 + u/Derivative[1][x][u]) == 0} *)

solR = DSolveValue[{eqR, x[top] == 0}, x[u], u] // Simplify (* 1/2 (top^2 - u^2) *)

solL = DSolveValue[{eqL, x[top] == 0}, x[u], u] // Simplify (* 1/2 (-top^2 + u^2) *)

Notice here top is the value of $u(0)$.

For $u(-5)=u(5)=0$, the graphic of solutions can be obtained with e.g.

ParametricPlot[{#, u}, {u, -5, 5}, PlotRange -> All, 
    RegionFunction -> Function[{x}, x < 0], AspectRatio -> 1/GoldenRatio]~Show~
   ParametricPlot[{#2, u}, {u, -5, 5}, 
    RegionFunction -> Function[{x}, x > 0]] & @@ ({solL, solR} /. c -> 0 /. 
   Solve[solR == 5 /. c -> 0 /. u -> 0, top][[1]])

enter image description here

As we can see, there exist 2 non-trivial solutions.

BTW it's easy to notice that $u = 0$ only if $x=\pm \frac{\text{top}^2}{2}$, so b.c.s like $u(-5)=u(6)=0$ don't form a well posed problem.

Remark

  1. Solution for $m=\frac{1}{2}$ case i.e.

    D[Sign[x] u[x], x] + D[u[x]^(1/2) D[u[x], x], x] == 0
    

    can be discussed in the same manner. Solution for $u(-6)=u(6)=0$ when $m=\frac{1}{2}$ can be plotted with e.g.

    ParametricPlot[{#, u}, {u, -10, 10}, PlotRange -> All, 
        RegionFunction -> Function[{x}, x < 0], AspectRatio -> 1/GoldenRatio]~Show~
       ParametricPlot[{#2, u}, {u, -10, 10}, RegionFunction -> Function[{x}, x > 0], 
        PlotRange -> All] & @@ ({solL, solR} /. c -> 0 /. 
       Solve[solR == 6 /. c -> 0 /. u -> 0, top][[1]])
    

    enter image description here

    As illustrated, there's only one non-trivial solution when $m=\frac{1}{2}$.

  2. One can directly solve neweq /. c -> 0 with DSolve. A warning will be generated then, but the results are correct.

xzczd
  • 65,995
  • 9
  • 163
  • 468
  • Wow, thanks again for such an answer @xzczd Just one last thing: is it bad-posed also in case where in place of $u^2$ I have $\sqrt{u}$? Because in your previous answer of two days your showed the same solution of the book in case $m=\frac{1}{2}$, which corresponds to $\sqrt{u}$ and the steady state case – Vefhug Sep 22 '20 at 15:21
  • @Vefhug Yes, see my update for more info. – xzczd Sep 22 '20 at 15:32
  • Thanks, but for the csae $m=\frac{1}{2}$, I can't understand which boundary conditons you imposed. Still $u(-6)=u(6)$ right? @xzczd – Vefhug Sep 22 '20 at 15:47
  • 1
    @Vefhug No, it's still $u(0)=\text{top}$. Then one can deduce $u=0$ only if $x=\pm 2\sqrt{\text{top}}$. – xzczd Sep 22 '20 at 15:53
  • Perfect, it's clear. The real last question ( I promise): for $u(-6)=u(6)=0$ we lose again uniquenuess and will obtain the same situation you plotted for the case $u^2$, right? – Vefhug Sep 22 '20 at 16:05
  • @Vefhug In short, when $m=2$ there'll always be 2 solutions for $u(\pm L)=0$, where $L>0$. – xzczd Sep 22 '20 at 16:11
  • I just wanted to know about $m=\frac{1}{2}$, for $m=2$ it's clear @xzczd – Vefhug Sep 22 '20 at 16:15
  • @Vefhug For $m=\frac{1}{2}$, there's always only one solution for $u(\pm L)=0$ where $L>0$. – xzczd Sep 22 '20 at 16:19
  • Thanks :-) @xzczd – Vefhug Sep 22 '20 at 16:20
  • @Vefhug Discussion for odevity has been simplified, have a look. BTW it's OK to wait for a day or even longer before accepting to see if better answer(s) come out :) . – xzczd Sep 22 '20 at 16:46
  • I asked a related question here, https://mathematica.stackexchange.com/questions/230896/nonlinear-system-for-chemotaxis where I am always in the biology contest – Vefhug Sep 28 '20 at 15:51