## Modified Midpoint (Gragg's) Method

For approximating the solution of the initial value problem*y ' = f(x, y)*,

*y(x*, the modified midpoint method begins by applying the midpoint method:

_{0}) = y_{0}*y*

_{0}= y(x_{0}), y_{1}= y_{0}+ h f(x_{0}, y_{0})*y*,

_{n+1}= y_{n-1}+ 2 h f(x_{n}, y_{n})*n = 1, 2, ... .*

Then at a certain step

*N*, where

*N*is an even integer, the oscillating error term is damped by redefining

*y*as

_{N}*y*.

_{N}**:=**½ (y_{N}+ y_{N - 1}+ h f(x_{N}, y_{N}) )The method then proceeds as if solving the initial value problem

*y ' = f(x, y)*,

*y(x*.

_{N}) = y_{N}The modified midpoint method is globally a second order method for which Richardson extrapolation may be applied to increase the order and accuracy.

### Function List

- double Graggs_Method( double (*f)(double, double), double y0, double x0, double x, int number_of_steps )

This function uses Gragg's modified midpoint method to return the estimate of the solution of the initial value problem,*y' = f(x,y); y = y0*when*x = x0*, at the argument*x*. The step size*h*used is given by*h = ( x - x0 ) / n*where*n*is the*number_of_steps*. The*number_of_steps*must be a positive even integer.

- double Graggs_Method_Richardson( double (*f)(double, double), double y0, double x0, double x, int number_of_steps, int richardson_columns )

This function uses Gragg's modified midpoint method together with Richardson extrapolation to return the estimate of the solution of the initial value problem,*y' = f(x,y); y = y0*when*x = x0*, at the argument*x*. The initial step size*h*used is given by*h = ( x - x0 ) / n*where*n*is the*number_of_steps*. The*number_of_steps*must be a positive even integer. The argument*richardson_columns*is the number of step size halving + 1 used in Richardson extrapolation so that if*richardson_columns = 1*then no extrapolation to the limit is performed.

*C* Source Code

- The file, graggs_method.c, contains versions of Graggs_Method_Method( ) and Graggs_Method_Richardson( ) written in
*C*.