# Adams-Bashforth and Adams-Moulton methods
## Definitions

Linear multistep methods are used for the numerical solution of ordinary differential equations, in particular the initial value problem
    $y'=f(t,y)\quad {\text{with}}\quad y(t_{0})=y_{0}\,.$
The Adams-Bashforth methods and Adams-Moulton methods are described on the Linear multistep method page.

## Derivation

There are (at least) two ways that can be used to derive the Adams-Bashforth methods and Adams-Moulton methods. We will demonstrate the derivations using polynomial interpolation and using Taylor's theorem for the two-step Adams-Bashforth method.

### Derive the two-step Adams-Bashforth method by using polynomial interpolation

From the w:Fundamental theorem of Calculus we can get
    $y(t_{n+1})=y(t_{n})+\int _{t_{n}}^{t_{n+1}}y'(t)\,dt\,.$         (1)
Set
    $A=\int _{t_{n}}^{t_{n+1}}y'(t)\,dt=\int _{t_{n}}^{t_{n+1}}f(t,y(t))\,dt.$         (2)
To get the value of $A$, we can use an interpolating polynomial $P(t)$ as an approximation of $f(t,y(t))$. The interpolation polynomial in the Lagrange form is a linear combination
    $L(x):=\sum _{j=0}^{k}y_{j}\ell _{j}(x)$
where
    $\ell _{j}(x):=\prod _{\begin{smallmatrix}0\leq m\leq k\\m\neq j\end{smallmatrix}}{\frac {x-x_{m}}{x_{j}-x_{m}}}\,.$
Then the interpolation can be
    $P(t)=f(t_{n},y_{n}){\frac {t-t_{n-1}}{t_{n}-t_{n-1}}}+f(t_{n-1},y_{n-1}){\frac {t-t_{n}}{t_{n-1}-t_{n}}}\,.$
Thus, (2) becomes
    $A=\int _{t_{n}}^{t_{n+1}}f(t,y(t))\,dt\approx \int _{t_{n}}^{t_{n+1}}P(t)\,dt=\int _{t_{n}}^{t_{n+1}}f(t_{n},y_{n}){\frac {t-t_{n-1}}{t_{n}-t_{n-1}}}+f(t_{n-1},y_{n-1}){\frac {t-t_{n}}{t_{n-1}-t_{n}}}\,dt$         (3)
Integrating and simplifying, the right hand side of equation (3) becomes
    ${\begin{array}{rcl}&&{\frac {1}{2}}(t_{n}+t_{n+1})(f(t_{n},y_{n})-f(t_{n-1},y_{n-1}))-t_{n-1}f(t_{n},y_{n})+t_{n}f(t_{n-1},y_{n-1})\\\\&=&{\frac {1}{2}}(t_{n}+t_{n+1}-2t_{n-1})f(t_{n},y_{n})+{\frac {1}{2}}(2t_{n}-t_{n+1}-t_{n})f(t_{n-1},y_{n-1})\,.\end{array}}$
Since $t_{n-1}$, $t_{n}$ and $t_{n+1}$ are equally spaced, then $t_{n}-t_{n-1}=t_{n+1}-t_{n}=h$. Therefore, the value of $A$ is
    $A={\frac {3}{2}}hf(t_{n},y_{n})-{\frac {1}{2}}hf(t_{n-1},y_{n-1})$
Putting this value back to (1) yields
    $y(t_{n+1})\approx y(t_{n})+{\frac {3}{2}}hf(t_{n},y_{n})-{\frac {1}{2}}hf(t_{n-1},y_{n-1})\,.$
Thus, the equation $y_{n+1}=y_{n}+{\frac {3}{2}}hf(t_{n},y_{n})-{\frac {1}{2}}hf(t_{n-1},y_{n-1})$ is the two-step Adams-Bashforth method.

### Derive the two-step Adams-Bashforth method by using Taylor's theorem

To simplify, let's set $f_{k}=f(t_{k},y_{k})$. Then the general form of Adams-Bashforth method is
    $y_{n+r}=y_{n+r-1}+h\sum _{k=1}^{r}\lambda _{k}f_{n+r-k}$         (4)
where $\sum _{k=1}^{r}\lambda _{k}=1$. For the two-step Adams-Bashforth method, let's set $\lambda _{1}=1-\lambda ,\lambda _{2}=\lambda$. Then (4) becomes
    ${\begin{aligned}y_{n+2}&=y_{n+1}+h((1-\lambda )f_{n+1}+\lambda f_{n})\\&=y(t_{n+1})+h((1-\lambda )y'(t_{n+1})+\lambda y'(t_{n}))\,.\end{aligned}}$
By using Taylor's theorem, expand $y'(t_{n})$ at $t_{n+1}$ to get
    $y_{n+2}=y(t_{n+1})+h((1-\lambda )y'(t_{n+1})+\lambda (y'(t_{n+1})-hy''(t_{n+1})+O(h^{2}))\,.$
Thus, the simplified form is
    $y_{n+2}=y(t_{n+1})+hy'(t_{n+1})-\lambda (h^{2})y''(t_{n+1})+O(h^{3})$         (5)
Expanding $y(t_{n+2})$ at $y(t_{n+1})$ yields
    $y(t_{n+2})=y(t_{n+1})+hy'(t_{n+1})+{\frac {1}{2}}(h^{2})y''(t_{n+1})+O(h^{3})\,.$         (6)
Subtracting (5) from (6) and then requiring the h^2 term to cancel makes $\lambda =-{\frac {1}{2}}$. The two-step Adams-Bashforth method is then
    $y_{n+2}=y_{n+1}+{\frac {3}{2}}hf(t_{n+1},y_{n+1})-{\frac {1}{2}}hf(t_{n},y_{n})$
Since
    $y(t_{n+2})-y_{n+2}=O(h^{3})\,.$
the local truncation error is of order $O(h^{3})$ and thus the method is second order. (See w: Linear multistep method#Consistency and order and w:Truncation error)

## Exercises

1. Derive three-step Adams-Bashforth method by using polynomial interpolation
Solution:
The initial problem is $y'=f(t,y).$ Then we can get:
    $y(t_{n+1})=y(t_{n})+\int _{t_{n}}^{t_{n+1}}y'(t)\,dt.$         (8)
let's set:
    $A=\int _{t_{n}}^{t_{n+1}}y'(t)\,dt=\int _{t_{n}}^{t_{n+1}}f(t,y(t))\,dt.$         (9)
Then,we can use P(t) as an interpolation of f(t,y(t)). To derive the three-step Adams-bashforth method, the interpolation polynomial is:
$P(t)=f(t_{n},y_{n}){\frac {(t-t_{n-1})(t-t_{n-2})}{(t_{n}-t_{n-1})(t_{n}-t_{n-2})}}+f(t_{n-1},y_{n-1}){\frac {(t-t_{n})(t-t_{n-2})}{(t_{n-1}-t_{n})((t_{n-1}-t_{n-2})}}+f(t_{n-2},y_{n-2}){\frac {(t-t_{n})(t-t_{n-1})}{(t_{n-2}-t_{n})(t_{n-2}-t_{n-1})}}$
Since $t_{n-2}$, $t_{n-1}$, $t_{n}$ and $t_{n+1}$ are equally spaced, then
$t_{n-1}-t_{n-2}=t_{n}-t_{n-1}=t_{n+1}-t_{n}=h$.
So the integral of each part of P(t) is :
${\frac {f(t_{n},y_{n})}{2h^{2}}}\int _{t_{n}}^{t_{n+1}}(t-t_{n-1})(t-t_{n-2})\,dt={\frac {23}{12}}hf(t_{n},y_{n})$
$-{\frac {f(t_{n-1},y_{n-1})}{h^{2}}}\int _{t_{n}}^{t_{n+1}}(t-t_{n})(t-t_{n-2})\,dt=-{\frac {4}{3}}hf(t_{n-1},y_{n-1})$
${\frac {f(t_{n-2},y_{n-2})}{2h^{2}}}\int _{t_{n}}^{t_{n+1}}(t-t_{n})(t-t_{n-1})\,dt={\frac {5}{12}}hf(t_{n-2},y_{n-2})$
Thus the approximate value of A is
$A\approx {\frac {23}{12}}hf(t_{n},y_{n})-{\frac {4}{3}}hf(t_{n-1},y_{n-1})+{\frac {5}{12}}hf(t_{n-2},y_{n-2})$
Put this value back to (8)
$y(t_{n+1})\approx y(t_{n})+{\frac {23}{12}}hf(t_{n},y_{n})-{\frac {4}{3}}hf(t_{n-1},y_{n-1})+{\frac {5}{12}}hf(t_{n-2},y_{n-2})$
Thus, the three-step Adams-Bashforth method is
$y_{n+1}=y_{n}+h\left({\frac {23}{12}}f(t_{n},y_{n})-{\frac {4}{3}}f(t_{n-1},y_{n-1})+{\frac {5}{12}}f(t_{n-2},y_{n-2})\right)$
2. Derive the second-order Adams-Moulton method by using Taylor's theorem
Solution:
To simplify, note $f,f'_{t},f'_{y}$ to represent $f(t_{n},y_{n}),f'_{t}(t_{n},y_{n}),f'_{y}(t_{n},y_{n})$.From Taylor expansion of the binary function (w:Taylor's theorem):
$f_{n+1}=f(t_{n+1},y_{n+1})=f+hf'_{t}+f'_{y}(y_{n+1}-y_{n})+O[h^{2}+(y_{n+1}-y_{n})^{2}]$
Then by using:
    $y_{n+1}=y_{n}+h((1-\lambda )f_{n}+\lambda f_{n+1})$         (10)
can get:
$f_{n+1}=f+hf'_{t}+(1-\lambda )hff'_{y}+\lambda hf_{n+1}f'_{y}+O(h^{2})$
Therefore, simplify this equation to get:
$f_{n+1}={\frac {f+hf'_{t}+(1-\lambda )hff'_{y}+O(h^{2})}{1-\lambda hf'_{y}}}$
Thus, subtitute $f_{n+1}$ into (10):
$y_{n+1}=y_{n}+h[(1-\lambda )f_{n}+\lambda f_{n+1}]$
$=y(t_{n})+hy'(t_{n})+\lambda h^{2}y''(x_{n})+O(h^{3})$
Combining the equation:
$y(t_{n+1})-y_{n+1}=O(h^{3})$
and Taylor expansion:
$y(t_{n+1})=y(t_{n})+hy'(t_{n})+{\frac {1}{2}}hy''(t_{n})+O(h^{3})$
can get $\lambda ={\frac {1}{2}}$. Therefore, the second-order Adams-moulton method is:
$y_{n+1}=y_{n}+{\frac {h}{2}}(f(t_{n+1},y_{n+1})+f(t_{n},y_{n}))$

## Predictor–corrector method

To solve an ordinary differential equation (ODE), a w:Predictor–corrector method is an algorithm that can be used in two steps. First, the prediction step calculates a rough approximation of the desired quantity, typically using an explicit method. Second, the corrector step refines the initial approximation using another means, typically an implicit method.
Here mainly discuss about using Adams-bashforth and Adams-moulton methods as a pair to construct a predictor–corrector method.

### Example: Adams predictor–corrector method

Let's start from the two-step Adams method. The prediction step is to use two-step Adams-bashforth:
$P_{n+1}=y_{n}+{\frac {3}{2}}hf(t_{n},y_{n})-{\frac {1}{2}}hf(t_{n-1},y_{n-1})$
Then, by using two-step Adams-moulton the corrector step can be:
$y_{n+1}=y_{n}+{\tfrac {1}{2}}h{\bigf(t_{n+1},P_{n+1})+f(t_{n},y_{n}){\big )}$
Also, by using four-step Adams-bashforth and Adams-moulton methods together, the predictor-corrector formula is:
${\begin{cases}P_{n+1}=y_{n}+{\frac {h}{24}}(55f(t_{n},y_{n})-59f(t_{n-1},y_{n-1})+37f(t_{n-2},y_{n-2})-9f(t_{n-3},y_{n-3}))\\y_{n+1}=y_{n}+{\frac {h}{24}}(9f(t_{n+1},P_{n+1})+19f(t_{n},y_{n})-5f(t_{n-1},y_{n-1})+f(t_{n-2},y_{n-2}))\\\end{cases}}$
Note, the four-step Adams-bashforth method needs four initial values to start the calculation. It needs to use other methods, for example Runge-Kutta, to get these initial values.

### Matlab programs

Four-step Adams predictor-corrector method:
Runge-Kutta method: