I'm experiencing some strange behavior when I try to use ParametricNDSolve
and Method -> {"EquationSimplification" -> "Residual"}
. (This is a follow up to my previous question.)
Essentially, I'm observing wild behavior for finely tuned values of the parameter L
.
f[r_] := 1 - 1/r;
soln = ParametricNDSolve[{r'[\[Lambda]]^2 ==
1 - L^2/r[\[Lambda]]^2*f[r[\[Lambda]]], r[0] == 1000},
r, {\[Lambda], 0, 2000}, {L},
Method -> {"EquationSimplification" -> "Residual"}]
Plot[Evaluate[
Table[r[L][\[Lambda]], {L, 10, 100, 10}] /. soln], {\[Lambda], 900,
1100}]
Plot[r[59.9][\[Lambda]] /. soln, {\[Lambda], 900, 1100}]
Plot[r[60][\[Lambda]] /. soln, {\[Lambda], 900, 1100}]
Plot[r[60.1][\[Lambda]] /. soln, {\[Lambda], 900, 1100}]
Plot[r[49.8][\[Lambda]] /. soln, {\[Lambda], 900, 1100}]
Plot[r[50][\[Lambda]] /. soln, {\[Lambda], 900, 1100}]
Plot[r[50.2][\[Lambda]] /. soln, {\[Lambda], 900, 1100}]
The solutions behave as expected for most values of L
, but for L=50
,L=60
, and possibly some other isolated values, the plot behaves badly. I'm very confused since the result should vary smoothly with $L$. I've solved this same differential equation in a different manner (Michael E2's solution in the question linked) and did not observe any erratic behavior, so I suspect it has to do with Method -> {"EquationSimplification" -> "Residual"}
. I was wondering why this is happening, and how to fix it if possible.
Another strange occurrence is when I replace "Residual"
with "Solve"
and run the code, abort it, and re-replace "Solve"
with "Residual"
, the code doesn't run. But after I save and run, it works fine. What's going on here?