As mentioned in the documentation for NDSolve it's often convenient to reduce a 2nd order ODE to a system of first order equations. When I do this however I seem to see a significant speed reduction in finding the solution.
Is there any reason this would be the case?
An Example:
Some definitions:
rstar[r_] := r + 2 M Log[r/(2 M) - 1];
M=1;
rinf=10000;
rH = 200001/100000;
r0 = 10;
wp=30;
ac=wp-8;
\[Lambda][l_] = l (l + 1);
Take the equation
eq[\[Omega]_,l_] := \[CapitalPhi]''[r] + (2 (r - M))/(
r (r - 2 M)) \[CapitalPhi]'[
r] + ((\[Omega]^2 r^2)/(r - 2 M)^2 - \[Lambda][l]/(
r (r - 2 M))) \[CapitalPhi][r] == 0;
Solve it with certain ICs:
init=-0.0000894423075560122420468703835499 +
0.0000447222944185058822813688948339 I;
dinit=-4.464175354293244250869336196691640386266791`30.*^-6 -
8.950483248390306670770345406047835993931665`30.*^-6 I;
sol := \[CapitalPhi] /.
Block[{$MaxExtraPrecision = 100},
NDSolve[{eq[1/10, 1], \[CapitalPhi][rinf] ==
init, \[CapitalPhi]'[rinf] == dinit}, \[CapitalPhi], {r, r0,
rinf}, WorkingPrecision -> wp, AccuracyGoal -> ac,
MaxSteps -> \[Infinity]]][[1]];
Now as set of first order equations
It turns out this system can be written as a first order set in terms of a related dependent variable $r^*$, and an effective potential $V$. Some more definitions:
init2=-0.8944230755601224204687038354990773373534 +
0.4472229441850588228136889483392836606307 I;
dinit2=-0.04472224961131835705979008430399621833410 -
0.08944221816744666391325700074861130268693 I;
r[rs_] := 2 (M + M ProductLog[E^(-1 + rs/(2 M))]);
V[rs_, \[Omega]_,l_] := \[Omega]^2 - (1 - (2 M)/r[rs]) (\[Lambda] [l]/(r[rs])^2 + (2 M)/(r[rs])^3);
rsH = N[rstar[rH], wp];
rsinf = N[rstar[rinf], wp];
rs0 = N[rstar[r0], wp];
Solve the first order system
sol2 := {R, Rp} /.
NDSolve[{Rp[rs] == R'[rs], Rp'[rs] == -V[rs, 1/10, 1] R[rs],
R[rsinf] == init2, Rp[rsinf] == dinit2}, {R, Rp}, {rs, rsinf,
rs0}, WorkingPrecision -> wp, AccuracyGoal -> ac,
MaxSteps -> \[Infinity]][[1]];
Now run:
sol // AbsoluteTiming
sol2 // AbsoluteTiming
I find that sol2 takes roughly three times as long, and for even large $\omega,\ell$ this time difference gets more pronounced