3
$\begingroup$

I'm trying to solve the following differential equation numerically:

s = NDSolve[{
      (z + 2 r[z] r'[z]) (1 + r'[z]^2) -z r[z] r''[z] == 0, 
      r[0.01] == 0.0001, 
      r'[0.01] == 10
     }, 
     r, {z, 0.01, 10}
    ]

But, when I set the initial condition to $z=0$, there are singularities, so I tried to set it as 0.01. Also, for $r(z=0.01)=0$ there is a singularity, so I set $r(z=0.01)=0.0001$.

However, when I try to solve the equation for any value that I put in the boundary conditions, I'm getting "step size is effectively zero; singularity or stiff system suspected." Is there any method to sort this out?

$\endgroup$
  • $\begingroup$ The singularity is clear: this equation algebraically implies $r'' = (1+r'^2)\frac{1}{r}$ plus other stuff not involving $r$. Because $1+r'^2\ge 1$ (assuming you want non-Complex solutions), it would be hard for $r$ to approach $0$ while its second derivative is blowing up like $1/r$. This indicates you will have extreme trouble finding any solution for small values of $r$. $\endgroup$ – whuber Oct 3 '12 at 15:56
1
$\begingroup$

This problem seems to be really stiff as whuber has pointed out. Using the BDF method and allowing NDSolve to ruminate about the order, didn't quite change the solution (z value where stiffness was encountered).

NDSolve[{(z + 2 r[z] r'[z]) (1 + r'[z]^2) - z r[z] r''[z] == 0, 
  r[0.01] == 0.0001, r'[0.01] == 10}, r, {z, 0.01, 10}, 
 MaxStepFraction -> 1/101, 
 Method -> {"BDF", "MaxDifferenceOrder" -> 5}]

Try these commands out as pointed out by several authors here and here:

These answers helped me out with issues I had with stiff equations.

You can look around and find heaps more information.

?NDSolve`BDF
?NDSolve`LSODA
$\endgroup$
  • $\begingroup$ Huh, I haven't said anything about these equations. You intended to address whuber? $\endgroup$ – J. M. is away Oct 3 '12 at 16:14
  • $\begingroup$ @J.M. Yes, I meant whuber... I think I got that wrong. $\endgroup$ – dearN Oct 3 '12 at 20:44

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.