1

I'm trying to solve an ODE with boundary values:

NDSolve[{(1 + Derivative[1][θ][ρ]^2) (3 θ'[ρ] Tan[θ[ρ]] - 4 Tanh[ρ]) + 
    Tanh[ρ] Tan[θ[ρ]] θ''[ρ] == 0, θ[0] == 0.5, θ[2] == Pi/2}, θ, {ρ, 0, 2}]

and getting the following error

Infinity::indet: "Indeterminate expression 0.\ ComplexInfinity encountered."

For some boundary values it works, especially if the start and end points are close together. As the points are moved apart, it starts to fail. Any idea why it is failing?

Feyre
  • 8,597
  • 2
  • 27
  • 46
  • 1
    I think this is a similar problem, which has a well-explained solution http://mathematica.stackexchange.com/q/124456/36788 – mikado Aug 25 '16 at 20:21
  • @mikado In this case, the OP omitted an important clue, "NDSolve::ndnum: Encountered non-numerical value for a derivative at ρ == 0.." The fact that this happens at the initial condition and not somewhere in the interior of the interval of integration suggests a singularity atρ == 0. Indeed, the coefficient ofθ''[ρ]vanishes becauseTanh[0] == 0. SinceNDSolvebegins by solving forθ''[ρ], and the1/Tanh[ρ]turns intoCoth[ρ], this is the source of theComplexInfinity`. This has a similar problem. – Michael E2 Aug 25 '16 at 22:29
  • @MichaelE2 I thought the same, but I checked it away from theta = 0. Try for example: NDSolve[{(1 + Derivative[ 1][\[Theta]][\[Rho]]^2) (3 \[Theta]'[\[Rho]] Tan[\[Theta][\ \[Rho]]] - 4 Tanh[\[Rho]]) + Tanh[\[Rho]] Tan[\[Theta][\[Rho]]] \[Theta]''[\[Rho]] == 0, \[Theta][0.1] == 0.5, \[Theta][2] == Pi/2 - 0.1}, \[Theta], {\[Rho], 0.1, 2}] – Damien Juan Aug 26 '16 at 20:08
  • @mikado Thanks for the link but when I try the shooting method manually, it doesn't work. There's seems to be no initial gradient for which it works. – Damien Juan Aug 26 '16 at 20:14
  • @DamienJuan Yeah, starting at 0 is one problem, but as you seemed to notice, starting at 0.1 leads to a different problem. – Michael E2 Aug 26 '16 at 21:46
  • @MichaelE2 I'm not sure what you mean, for me both give the ComplexInfinity error. – Damien Juan Aug 27 '16 at 20:06
  • @DamienJuan When you start integration at ρ == 0, the infinity is "your fault", because one gets the initial value for θ''[0] by dividing by Tanh[0]; when you start at ρ == 0.1, somewhere down the line the shooting method tries {θ[0.1], θ'[0.1]} == {0., 0.} as an initial condition which also leads to infinity for θ''[0] from the factor Tan[θ[ρ]] in front of the second derivative. That's the fault of NDSolve. I suppose it tries {0., 0.} because it cannot satisfy the BCs with θ[0.1] == 0.5. – Michael E2 Aug 27 '16 at 21:18

0 Answers0