Midpoint MethodThe midpoint method is an explicit method for approximating the solution of the initial value problem y' = f(x,y); y(x0) = y0 at 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(h2).
Then the differential equation becomes
y(x+h) = y(x-h) + 2h f(x,y) + (h3).
The approximation yn for y(x0+nh) is then given recursively by
yn+1 = yn-1 + h f(xn,yn)
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.
- 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 when x = a, at a + nh where for
1 < n < number_of_steps and h is the step size. On input, y is the value of y(x) at
x = a and y 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.