In the notebook attached, I solve an ordinary differential equations with the AdamsBM method discussed here, and plot the error of the method as a function of t.
How may I plot the DifferenceOrder of the method as a function of t?
In the notebook attached, I solve an ordinary differential equations with the AdamsBM method discussed here, and plot the error of the method as a function of t.
How may I plot the DifferenceOrder of the method as a function of t?
Add this before the last line of of the definition AdamsBM[data_]["Step"[rhs_, t_, h_, y_, yp_]]:
Sow[{t + hnew, knew}, "Adams order"];
Then
{sol, {orders}} = Reap[
NDSolve[{x''[t] + x[t] == Sin[3 t], x[0] == 1, x'[0] == 0},
x, {t, 0, 2 \[Pi]}, Method -> AdamsBM, WorkingPrecision -> 32],
"Adams order"];
To plot:
Listplot[orders]
Or skip the modification and just do:
sol = NDSolve[{x''[t] + x[t] == Sin[3 t], x[0] == 1, x'[0] == 0},
x, {t, 0, 2 \[Pi]}, Method -> AdamsBM, WorkingPrecision -> 32, InterpolationOrder -> All];
And plot:
solIF = x /. First@sol;
Transpose@{solIF[[3, 1]], (Length /@ solIF[[4]]) - 1} // ListPlot
Thank you.
You’re welcome. ![]()