Docsity

Simpson's Rule: Calculating Area Under a Curve using Parabolas, Study notes of Calculus

Toggle sidebar
bg1
CHAPTER 6: Definite Integrals and Area Under the Curve 121
Simpson’s Rule
Simpson’s Rule takes advantage of the fact that most functions are smooth curves, not straight line
segments. Simpson’s rule fits a parabola through the top three corners of each pair of strips and
sums up the area under all of the parabolas. In Fig. 6.16 we have shown one pair of strips and the
parabola that fits this pair. Our first task will be to find the correct values of a, b and c in order
that the parabola 2
yax bxc goes through the top three corners. Once we have found them
then it is straightforward to find the area under the parabola. It is
2323
11 2
32 3
() 2
xxx
xx
xax bx c dx ax bx cx a x c x
 

 


. (6.27)
Now let’s turn to the task of finding the values of a, b and c. As shown in Fig. 6.16, the three
points that the parabola must go through have coordinates (x, yL ), (0, yM ) and (+x, yR ).
Substituting these into the equation 2
yax bxc
 gives three equations in the three unknowns
a, b and c:
2
2
2
00
()()
R
M
L
yaxbxc
ya bc
ya x b xc
 


(6.28)
The second equation immediately gives c = yM . Substituting this into the first and third equations
gives the following pair of equations in the unknowns a and b:
2
2
R
M
L
M
x
axbyy
x
axbyy


(6.29)
Adding the equations, we get
2
2
2
L
RM
yy y
ax

. (6.30)
Substituting the values found for a and c into the formula for the area under the parabola given on
the previous page, we get the formula shown on the next page for the area under the parabola.
Figure 6.16 Simpson’s rule
breaks the integration region
into a large number of pairs of
strips. It then fits a parabola
through the top three corners
of each pair. This figure
shows one such pair.
ya
x
b
x
c

2
)(
R
M
L
x
y=f
y
y
y
xx
+
y
x
pf3

Partial preview of the text

Download Simpson's Rule: Calculating Area Under a Curve using Parabolas and more Study notes Calculus in PDF only on Docsity!

Simpson’s Rule

Simpson’s Rule takes advantage of the fact that most functions are smooth curves, not straight line segments. Simpson’s rule fits a parabola through the top three corners of each pair of strips and sums up the area under all of the parabolas. In Fig. 6.16 we have shown one pair of strips and the parabola that fits this pair. Our first task will be to find the correct values of a , b and c in order that the parabola ya x^2  b xc goes through the top three corners. Once we have found them then it is straightforward to find the area under the parabola. It is

2 1 3 1 2 2 3 ( ) 3 2 3 2

x x x x a x^ b x^ c dx^ a x^ b x^ c x^ x^ x a^ x^ c^ x

   

 ^ ^ ^ ^ ^ ^  ^ ^ ^ .^ (6.27)

Now let’s turn to the task of finding the values of a , b and c. As shown in Fig. 6.16, the three points that the parabola must go through have coordinates ( x , yL ), (0, yM ) and (+ x , yR ). Substituting these into the equation ya x^2  b xc gives three equations in the three unknowns a , b and c :

2

2

2

R

M

L

y a x b x c

y a b c y a x b x c

 ^ ^ 

 ^ ^ ^  ^ 

The second equation immediately gives c = yM. Substituting this into the first and third equations gives the following pair of equations in the unknowns a and b :

2

2

R M

L M

x a x b y y

x a x b y y

^ ^  ^ ^ ^ 

Adding the equations, we get

2

a y^ L^ yR^ yM x

Substituting the values found for a and c into the formula for the area under the parabola given on the previous page, we get the formula shown on the next page for the area under the parabola.

Figure 6.16 Simpson’s rule breaks the integration region into a large number of pairs of strips. It then fits a parabola through the top three corners of each pair. This figure shows one such pair.

ya x^2  b xc

 

( ) R

M

L

y y = f^ x

y

y

x + x

y

x

area under parabola 2 3 2 3

( 2 ) 2 3 L^ R^ M^ M

a x c x

x y y y y x

3 L^ M^ R

x y y y

Notice that the coefficients of yL , yM and yR inside the brackets are 1, 4 and 1. Notice also that the area does not depend on where the pair of strips is located. We located them at the origin only to make the task of finding a , b and c easier. Now suppose that we have three strip pairs. Then the area under three parabolas is

area under 3 parabolas 3 ( 0 4 1 2 ) 3 ( 2 4 3 4 ) 3 ( 4 4 5 6 ) x x x y y y y y y y y y

or rearranging,

area under 3 parabolas =  1 0 4 1 2 2 4 3 2 4 4 5 16 

x y y y y y y y

Notice the pattern of the coefficients of the y ’s inside the brackets; it starts with 1 4 and ends with 4 1, and in the interior it alternates 4, 2, 4, 2, .... This pattern generalizes to any number of pairs of strips.

area of strips =  0 4 1 2 2 4 3 2 4 4 1 

3 n^ n

x n y y y y y y (^)  y

Notice that in this formula n must be an even number. (This is because the region between x = a and x = b must be divided in such a way that all strips occur in pairs.) As usual the first and last y ’s represent the value of the function at the endpoints x = a and at x = b.

Here is Visual Basic code that implements Simpson’s Rule. To use it see the instructions on page 118.

Public Function Simpson (A, B, N) Dim X As Double, Dx As Double, Sum As Double, I As Integer 'this function integrates a function called Func(x) between x=A and x=B 'using Simpson's rule with N strips.

N = (N \ 2) * 2 'Make sure N is even. The \ operator does integer division. Dx = (B - A) / N 'Dx is the width of a strip Sum = 0

For I = 0 To N 'the main loop X = A + I * Dx If I = 0 Or I = N Then 'I for one of the endpoints Sum = Sum + Func(X) ElseIf I Mod 2 = 1 Then 'I is odd Sum = Sum + 4 * Func(X) Else 'I is even Sum = Sum + 2 * Func(X) End If Next I

Simpson = Sum * Dx / 3 End Function