MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

NDSolve for BVP: Increasing MaxIterations, reverse direction

  • To: mathgroup at
  • Subject: [mg124250] NDSolve for BVP: Increasing MaxIterations, reverse direction
  • From: gac <g.crlsn at>
  • Date: Sat, 14 Jan 2012 17:11:06 -0500 (EST)
  • Delivered-to:

I am trying to solve a boundary value problem with NDSolve.  I have two questions:

1. How do I increase MaxIterations?
2. Can I reverse the direction of integration of NDSolve?

My Mathematica 8 notebook to solve the modified spherical Bessel equation is appended below.  I am comparing the NDSolve solution to the exact solution BesselI[2,r]/Sqrt[r].  In fact, for this exercise, I'm trying to force NDSolve to give me the exact solution. I also include a parameter sigma that should evaluate to 1.

I can't seem to get around the error message: "FindRoot::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations."  How do I increase MaxIterations in NDSolve?

Also, I think I might get a better result if NDSolve would integrate from rEnd to r0 instead of r0 to rEnd.  Can I specify that NDSolve should solve the problem in the reverse direction?

Thanks very much.


rTiny = 10^-12;
r0 = rTiny;
rEnd = 1;
\[Phi]Exact[r_] := Sqrt[Pi/(2 r)] BesselI[2, r];
\[Phi]0 = \[Phi]Exact[r0];
\[Phi]p0 = D[\[Phi]Exact[r], r] /. r -> r0;
\[Phi]End = \[Phi]Exact[rEnd];

sol = NDSolve[{r^2 \[Phi]''[r] + 2 r \[Phi]'[r] - r^2 \[Phi][r] == 2 \[Sigma][r] \[Phi][r], \[Sigma]'[r] == 0, \[Phi][r0] == \[Phi]0, \[Phi]'[r0] == \[Phi]p0, \[Phi][rEnd] == \[Phi]End}, {\[Phi], \[Sigma]}, r, WorkingPrecision -> 20];

Plot[{\[Phi][r] /. First[sol], \[Phi]Exact[r]}, {r, 0, rEnd}, PlotStyle -> {Red, Blue}]
\[Sigma][0] /. First[sol]

  • Prev by Date: Re: Vectors
  • Next by Date: Re: Plotting a line with color changing as a function of position
  • Previous by thread: Re: remote kernel problem
  • Next by thread: How to check whether an infinite set is closed under addition?