2
$\begingroup$

I am trying to solve the following non-linear ODE numerically:

M = 5 ; g = 12/10; 
NDSolve[{-x*D[h[x], x] + 2*D[((h[x]/(h[x] + M*(1 - h[x])))*(1 - 
2*g*M*x*(1 - h[x])*D[h[x], x])), x] == 0, h[0] == 0 , h[10] == 1}, h[x], {x, 0, 10}]

where M=5 and g=1.2. The ODE is subject to the following: h[x=0]=0 and h[x=10]=1. I tried using NDSolve with no success. I very much appreciate if anyone could help with the solution over 0<x<10.

$\endgroup$
1
  • $\begingroup$ What is the underlying physical problem you try to solve? $\endgroup$ Commented Oct 18, 2023 at 9:15

2 Answers 2

2
$\begingroup$

Your problem is a boundary value problem. This can be solved by e.g. the shooting method or by specifying Dirichlet conditions.

A solution using Dirichlet conditions can be obtained like the following, However, MMA complains that the equation may not be stable.

sol[x_] =  h[x] /. NDSolve[{-x*D[h[x], x] + 2*D[((h[x]/(h[x] + M*(1 -h[x])))*(1 - 
             2*g*M*x*(1 - h[x])*D[h[x], x])), x] == 0, 
     DirichletCondition[h[x] == 1, x == 10], h[0] == 0}, 
    h[x], {x, 0, 10}][[1]]

Plot[sol[x], {x, 0, 10}]

enter image description here

A solution using the shooting method is more complicated and you will have to dig in.

$\endgroup$
2
  • $\begingroup$ Thank you so much for your valuable response. $\endgroup$
    – Zazu
    Commented Oct 16, 2023 at 21:09
  • 1
    $\begingroup$ NDSolve obtains this solution using the Finite Element method, which implicitly assumes that the solution is reasonably well behaved. Unfortunately, it can be shown that the ODE is singular at both h[x] = 0 and h[x] = 1. $\endgroup$
    – bbgodfrey
    Commented Oct 17, 2023 at 3:58
2
$\begingroup$

With the boundary conditions given in the question, the ODE has no solution, as can be seen as follows. The ODE with constants as specified is

eq = -x*D[h[x], x] + 2*D[((h[x]/(h[x] + 5*(1 - h[x])))*
    (1 - 12*x*(1 - h[x])*D[h[x], x])), x] == 0

Solving eq for the second-derivative yields:

Solve[eq, h''[x]] // Simplify // First // First
(* (h''[x] -> -((h'[x] (96 h[x]^3 - 40 h[x] (-3 + x + 6 x h'[x]) + 
    8 h[x]^2 (-27 + 2 x + 12 x h'[x]) + 5 (-2 + 5 x + 24 x h'[x])))
    /(24 x (-1 + h[x]) h[x] (-5 + 4 h[x]))) *)

Thus, the ODE is singular not only at x = 0 but also at h[x] equal to any of {0, 1, 5/4}, for any x; i.e., at both boundaries. To understand this behavior better, let us attempt to expand h[x] at x = 0.

Thread[(CoefficientList[Normal@Series[eq, {x, 0, 1}], x] // Simplify) == 0]
(* ((2 (5 - 60 h[0] + 108 h[0]^2 - 48 h[0]^3) h'[0])/((5 - 4 h[0])^2)) == 0, 
    -(1/((-5 + 4 h[0])^3))((-5 + 4 h[0])^3 h'[0] + 
    32 (-35 + 105 h[0] - 90 h[0]^2 + 24 h[0]^3) h'[0]^2 + 
    2 (25 - 620 h[0] + 1560 h[0]^2 - 1344 h[0]^3 + 384 h[0]^4) h''[0]) == 0 *)

If h[0] == 0, then the first equation yields h'[0] == 0 and the second equation yields h''[0] == 0. Higher order expansions indicate that all derivatives of h{x] must vanish, which cannot be. So, no series expansion exists at x = 0 for h[0] = 0. On this basis, it seems likely that the ODE cannot be solved numerically for the specified boundary conditions. On the other hand, from the first equation of the series expansion,

2 (5 - 60 h[0] + 108 h[0]^2 - 48 h[0]^3) == 0

allows h'[0] to assume any value!

SolveValues[%, h[0]] // N
(* {0.100805, 0.72616, 1.42304} *)

In other words, if h[0] is equal to any these three values, a series solution can be constructed at x = 0, and h[x] then solved numerically in the vicinity. Even then, it seems unlikely that any h[10] boundary condition could be satisfied simultaneously.

The numerical solution obtained by Daniel Huber employes the Finite Element method. Ordinarily, this approach works well. Here, however, the ODE is so singular that it apparently does not.

$\endgroup$

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.