# Plot the DifferenceOrder with AdamsBM method in NDSolve?

**URL:** <https://community.wolfram.com/t/plot-the-differenceorder-with-adamsbm-method-in-ndsolve/12014>\
**Category:** Questions\
**Tags:** equation-solving, graphics-and-visualization, numerical-computation\
**Created:** [February 25, 2018, 5:44pm UTC](https://community.wolfram.com/t/plot-the-differenceorder-with-adamsbm-method-in-ndsolve/12014 "2018-02-25T17:44:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michelecastellana](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@michelecastellana](https://community.wolfram.com/u/michelecastellana)\
**Post date:** [February 25, 2018, 5:44pm UTC](https://community.wolfram.com/t/plot-the-differenceorder-with-adamsbm-method-in-ndsolve/12014/1 "2018-02-25T17:44:34Z")

</div>

In the notebook attached, I solve an ordinary differential equations with the AdamsBM method discussed [here](http://reference.wolfram.com/language/tutorial/NDSolvePlugIns.html), 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?

---

<div class="post-metadata">

**Author:** ![mroge02](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mroge02/32/28775_2.png) [@mroge02](https://community.wolfram.com/u/mroge02)\
**Post date:** [February 27, 2018, 3:59am UTC](https://community.wolfram.com/t/plot-the-differenceorder-with-adamsbm-method-in-ndsolve/12014/2 "2018-02-27T03:59:04Z")

</div>

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

```

 ![76331Example.png](https://global.discourse-cdn.com/wolfram/original/2X/5/5be0575be12b078454cc265a408ca92340412e20.png)

---

<div class="post-metadata">

**Author:** ![michelecastellana](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@michelecastellana](https://community.wolfram.com/u/michelecastellana)\
**Post date:** [February 27, 2018, 8:12am UTC](https://community.wolfram.com/t/plot-the-differenceorder-with-adamsbm-method-in-ndsolve/12014/3 "2018-02-27T08:12:30Z")

</div>

Thank you.

---

<div class="post-metadata">

**Author:** ![mroge02](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mroge02/32/28775_2.png) [@mroge02](https://community.wolfram.com/u/mroge02)\
**Post date:** [February 28, 2018, 4:19am UTC](https://community.wolfram.com/t/plot-the-differenceorder-with-adamsbm-method-in-ndsolve/12014/4 "2018-02-28T04:19:20Z")

</div>

You’re welcome. 🙂
