Message Boards Message Boards

GROUPS:

Plot the DifferenceOrder with AdamsBM method in NDSolve?

Posted 10 months ago
769 Views
|
3 Replies
|
0 Total Likes
|

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?

Attachments:
3 Replies

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

enter image description here

Posted 10 months ago

Thank you.

You're welcome. :)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract