Everything2
Near Matches
Ignore Exact
Full Text
Everything2

Trapezoidal Rule

created by Clobbersaurus

(idea) by Professor Pi (3.1 wk) (print)   ?   2 C!s I like it! Tue Aug 07 2001 at 23:21:05

The Trapezoidal rule is a mathematical method for doing numerical integration ("calculating the area under a curve"). This is often useful when an exact integral does not exist, can not easily be obtained, or is mathematically too time consuming for repetitious automated calculations.

One approach to obtain a numerical solution of an integral is to approximate the function with an nth order polynomial, since these are relatively simple to integrate. The choice of the order of the polynomial depends on the required accuracy (higher order generally results in a higher precision), and the number data points over the selected interval (higher order requires more data points).

Consider the function f(x). We want to calculate the area under the curve over the interval a ≤ x ≤ b:

         b
     I = ∫ y(x)dx
         a

The simplest polynomial approximation, a 0th order polynomial would draw a straight horizontal line, halfway between y(a) and y(b), marking a rectangle. The area of this rectangle is simply the length times the height. But that is not a very accurate method; the approximation of the area yields a relatively large error.

A better approximation is to approximate the curve with a 1st order polynomial; a line that goes trough the points a and b. This can be seen in the following figure:

   y(x)

y(b)_|                  ..
     |               ./|C
     |              ./ |
     |             ./  |
     |             /   |           .....  y(x)
     |            /.   |
     |           / .   |
     |          / .    |
     |       . /.      |
y(a)_|     . D|        |
     |    .   |        |
     | ..     |        |
     |.       |        |
     |        |        |
     |_______A|________|B___ x
              a        b
Over the range a ≤ x ≤ b, the function y(x) is now approximated with a trapezoid marked by ABCD. The area of the trapezoid is:
     ABCD = 1/2 AB(AD + BC) = 1/2 (b-a)(y(a) + y(b))

We can gain a higher precision if we divide the interval a ≤ x ≤ b up into several equal parts, a = x0, x1, x2, ..., xn-1, xn = b. We find the corresponding y values, y0 = y(x0), y1 = y(x1), y2 = y(x2), ..., yn = y(xn). Each part has a width equal to h = (b - a)/n

The Trapezoidal Rule for approximating the integral now becomes:

     b
     ∫ y(x)dx = h/2(y0 + 2y1 + 2y2 + ... + 2yn-1 + yn)
     a

Example: Let's approximate the integral of the function:

     y = x2 + 2x -3

over the range 3 ≤ x ≤ 4. The exact solution is straightforward:

     4                            4
     ∫ y(x)dx = [ 1/3 x3 + x2 - 3x] = 76/3 - 9 = 16.3333...
     3                            3

Now let's try the numerical solution. First generate a table with x-, and y-values for the selected interval:


 n       xn      y
 0      3.0    12.00   
 1      3.2    13.64
 2      3.4    15.36
 3      3.6    17.16
 4      3.8    19.04
 5      4.0    21.00

The numerical solution is given by (h=1/5):

     4                
     ∫ y(x)dx = (1/10)(12.00 + 2×13.64 + 2×15.36 + 2×17.16 + 2×19.04 + 21.00) = 16.34
     3                

The example shows that the trapezoidal rule can obtain relatively accurate results (in this case an error of approximately 0.04%) with only a small number of simple calculations. The error between the exact integral (I) and the numerical solution In is given by:

     I - In = -1/12 h3y"(ε)

with a ≤ ε ≤ b

Of course, the integral can also be calculated with higher order polynomial approximations. The 2nd order polynomial approximation is called Simpson's Rule.


printable version
chaos

approximating square roots using first-order Taylor series Simpson's Rule numerical integration X
Π (Π) vs Π (Π) B Integration Common
simple phi f(x) A
N Taylor polynomial Server Time The Discordian Illuminati
method A Thousand Points of Light Taylor Series Fuel cell
binary Philosophy FAQ integrated
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help


cooled by fuzzy and blue

Cool Staff Picks
Look at this mess the Death Borg made!
Serving saké
Russian Rock'n'Roll
Paul Wellstone
Barbary lion
Things I need to tell my teenaged daughters about boys
Darwin's Finches
Everything2 is a community
Over-educated Supervillains
Diane Arbus
Genetic drift
Measurements based on the human body
Father and Son
Bill Hicks
New Writeups
Scaevola
Homosexual marriage(idea)
SteveMurrayFromNZ
Waiver(idea)
nailbiter
nerve stapling(thing)
locke baron
Multiple Myeloma(thing)
SubSane
blonde, freckles, skinny, short(person)
arcanamundi
A Ruba'iyat for May(person)
riverrun
Timed Writing(idea)
auraseer
Fling(fiction)
StrawberryFrog
Iron Man(review)
devolution
Misogyny and Porn, East to West - An Empirical Analysis(idea)
devolution
Korea is a place that refuses to stand still(idea)
Beanie127
The Pacifist Soldier(fiction)
VergilKint
Distilled from Dreams(fiction)
Scaevola
Roman marriage(thing)
rootbeer277
m&m's Ice Cream Treats(review)
This page courtesy of The Everything Development Company