Mathematics Source Library
C & ASM

 Home Differential Equations Home Euler's Method Trapezoidal Method Midpoint Method Modified Midpoint (Gragg's) Method Runge-Kutta Methods Adams-Bashforth Adams-Moulton Methods Embedded Runge-Kutta Methods Gragg - Bulirsch-Stoer Method Second Order Diff Eq Methods

## Modified Midpoint (Gragg's) Method

For approximating the solution of the initial value problem y ' = f(x, y), y(x0) = y0, the modified midpoint method begins by applying the midpoint method:

y0 = y(x0), y1 = y0 + h f(x0, y0)

yn+1 = yn-1 + 2 h f(xn, yn), n = 1, 2, ... .

Then at a certain step N, where N is an even integer, the oscillating error term is damped by redefining yN as

yN  := ½ (yN + yN - 1 + h f(xN, yN) ).

The method then proceeds as if solving the initial value problem y ' = f(x, y), y(xN) = yN .
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.