Jump to content

Midpoint method

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Khiz (talk | contribs) at 02:56, 17 November 2009. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Illustration of the midpoint method assuming that equals the exact value The midpoint method computes so that the red chord is approximately parallel to the tangent line at the midpoint (the green line).

In numerical analysis, a branch of applied mathematics, the midpoint method is a one-step method for solving the differential equation

numerically, and is given by the formula

for Here, is the step size — a small positive number, and is the computed approximate value of

The name of the method comes from the fact that in the formula above the function is evaluated at which is the midpoint between at which the value of y(t) is known and at which the value of y(t) needs to be found.

The error at each step of the midpoint method is of order Thus, while more computationally intensive than Euler's method, the midpoint method generally gives more accurate results.

The method is an example of a class of higher-order methods known as Runge-Kutta methods.

Derivation of the midpoint method

Illustration of numerical integration for the equation Blue: the Euler method, green: the midpoint method, red: the exact solution, The step size is
The same illustration for It is seen that the midpoint method converges faster than the Euler method.

The midpoint method is a refinement of the Euler's method

and is derived in a similar manner. The key to deriving Euler's method is the approximate equality

which is obtained from the slope formula

and keeping in mind that

For the midpoint method, one replaces (3) with the more accurate

when instead of (2) we find

One cannot use this equation to find as one does not know at The solution is then to use a Taylor series expansion exactly as if using the Euler method to solve for :

which, when plugged in (4), gives us

<math>y(t + h) \approx y(t) + hf\left(t + \frac{h}{2}, y(t) + \frac{h}{2}f(t, y(t))\right)</smath>

and the midpoint method (1).

Sample Fortran Program

      Program Calc

      Double Precision f,y,a,b,J,mult,sum,c1,c2,ci
      Sum=0
      c2=0
      ci=0


      Print*,'Enter the start and end of the interval'
      Read*,a,b
      If (b.gt.a) then
         goto 1
      Else
         goto2
      End If
      
  1   Do J=a,b,.00000001
         c1=J
         Y=F(((c1+c2)/2))
         Mult=Y*.00000001
         Sum=sum+mult
         c2=c1
      End Do

  2   Do J=a,b,-.00000001
         c1=J
         Y=F(((c1+c2)/2))
         Mult=Y*.00000001
         Sum=sum+mult
         c2=c1
      End Do

      Print*,Sum
  3   Format (F20.5)
      End

      Double Precision Function f(x)
      Double Precision x

      F=(4)/((x**2)+1)

      Return
      End

See also

References

  • Griffiths,D. V.; Smith, I. M. (1991). Numerical methods for engineers: a programming approach. Boca Raton: CRC Press. p. 218. ISBN 0-8493-8610-1.{{cite book}}: CS1 maint: multiple names: authors list (link)