## Midpoint Method

The midpoint method is an explicit method for approximating the solution of the initial value problem*y' = f(x,y); y(x*at

_{0}) = y_{0}*x*for a given step size

*h*. For the midpoint method the derivative of

*y(x)*is approximated by the symmetric difference

*y'(x) = ( y(x+h) - y(x-h) ) / 2h + O(h*.

^{2})Then the differential equation becomes

*y(x+h) = y(x-h) + 2h f(x,y) + (h*.

^{3})The approximation

*y*for

_{n}*y(x*is then given recursively by

_{0}+nh)*y*

_{n+1}= y_{n-1}+ h f(x_{n},y_{n})for

*n = 1, 2, ...*.

Locally the midpoint method is a third order method and therefore globally a second order method.

The midpoint method is a stable and convergent method but it is only weakly stable, small perturbations in the initial conditions give rise to growing oscillations.

As a rule, use of the midpoint method should be avoided.

### Function List

- void Midpoint_Method( double (*f)(double, double), double y[ ], double a, double h, int number_of_steps )

This function uses the midpoint method to return the estimate of the solution of the initial value problem,*y' = f(x,y); y = y[0]*when*x = a*, at*a + nh*where for*1 < n < number_of_steps*and*h*is the step size. On input,*y[0]*is the value of*y(x)*at

x =*a*and*y[1]*is the value of*y(x)*at*x = a + h*. On output*y[n]*is the value of*y(x)*at*x = a + n h*for*1 < n < number_of_steps*.

*C* Source Code

- The file, midpoint_method.c, contains the version of Midpoint_Method( ) written in
*C*.