Matematika

Section 5.7
Numerical Integration
Math 1a
Introduction to Calculus

April 25, 2008

Announcements


Midterm III is Wednesday 4/30 in class (covers §4.9–5.6)



Friday 5/2 is Movie Day!



Final (tentative) 5/23 9:15am




Problem Sessions Sunday, Thursday, 7pm, SC 310



.

.

.

.

.

.

Announcements




Midterm III is Wednesday 4/30 in class (covers §4.9–5.6)



Friday 5/2 is Movie Day!



Final (tentative) 5/23 9:15am



Problem Sessions Sunday, Thursday, 7pm, SC 310



Office hours Tues, Weds, 2–4pm SC 323

.


.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule


.

.

.

.

.

.

Theorem (Integration by Parts)
Let u and v be differentiable functions. Then


u(x)v′ (x) dx = u(x)v(x) − v(x)u′ (x) dx.
Succinctly,




u dv = uv −



v du.

.

.

.

.

.

.

Theorem (Integration by Parts)

Let u and v be differentiable functions. Then


u(x)v′ (x) dx = u(x)v(x) − v(x)u′ (x) dx.
Succinctly,



u dv = uv −



v du.

Theorem (Integration by Parts, definite form)


a

b


¯b ∫
¯
u dv = uv¯¯ −
a

a

b

v du.

.

.

.

.


.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.


.

.

Why estimate an integral when we have the FTC?









Antidifferentiation is
“hard”
Sometimes
antidifferentiation is
impossible

Sometimes all we need
is an approximation
These methods actually
work pretty well!

.

.

.

.

.

.

Trapezoids instead of rectangles



.f(xi−1 )

In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )

In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

f(xi−1 ) + f(xi )
∆x
2

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

.xi



f(xi−1 ) + f(xi )
∆x
2

The smaller the
intervals, the better the
approximation
.

.

.

.

.

.

The Trapezoidal Rule
Definition
Divide the interval [a, b] up into n pieces. Let ∆x =
xi = a + i∆x, and yi = f(xi ) for each i from 1 to n.

b−a
,
n



The (n + 1)-point Trapezoidal Rule approximation to

a

is given by
Tn (f) =

n

f(xi−1 ) + f(xi )

2

i=1

b

f(x) dx

∆x

y
+ yn
y + y 1 y 1 + y2
+
+ · · · + n −1
= ∆x 0
2
2
2
)
∆x (
=
y0 + 2y1 + 2y2 + · · · + 2yn−1 + yn
2

[

.

.

.

]

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Trapezoidal Rule and n = 4.

.

.

.

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Trapezoidal Rule and n = 4.

Solution
The set of values is
} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44

So

(
)
1
1
4
9
16
Tn (f) =
0+2·
+2·
+2·
+
2·4
16
16
16 16
(
)
1 2 + 8 + 18 + 16
=
8
16
44
11
=
=
128
32
.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



1

2

1
dx
x

with the Trapezoidal Rule and n = 8.

.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



1

2

1
dx
x

with the Trapezoidal Rule and n = 8.

Solution
0.694122

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.

∆A =

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

.
.xi−1

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.
)
(
xi−1 + xi
∆x
∆A = f
2

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

.
.xi−1



.xi

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.
)
(
xi−1 + xi
∆x
∆A = f
2
Again, the smaller the
intervals, the better the
approximation

.

.

.

.

.

.

The Midpoint Rule
Definition

b−a
, and
n
xi = a + i∆x for each i from 1 to n.
∫ b
f(x) dx is
The (n + 1)-point Midpoint Rule approximation to
Divide the interval [a, b] up into n pieces. Let ∆x =

a

given by

(
)
n

xi−1 + xi
Mn (f) =
f
∆x
2
i=1
)
(
)
(
))
( (
x1 + x 2
xn−1 + xn
x0 + x1
+f
+ ··· + f
= ∆x f
2
2
2

.

.

.

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Midpoint Rule and n = 4.

.

.

.

.

.

.

Example
Example
Estimate



1

0

x2 dx with the Midpoint Rule and n = 4.

Solution
The set of midpoints is

{

So
Mn (f) =

0, 18 , 38 , 58 , 78

}

( )2 ( ) 2 ( )2 ( ) 2 )
1(
0 + 81 + 38 + 85 + 78
4
(
)
1 1 + 9 + 25 + 49
=
4
64
84
21
=
.
=
256
64
.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



2

1

1
dx
x

with the Midpoint Rule and n = 8.

.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



2

1

1
dx
x

with the Midpoint Rule and n = 8.

Solution
0.692661

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Parabolas instead of lines





.

Trapezoidal Rule
approximates the
function with a line
Why not use a parabola?
A section of a parabola
passing through equally
spaced points is

∆x
(y + 4y1 + y2 )
3 0


need an even number of
points

.

.

.

.

.

.

Simpson’s Rule
Definition
Divide the interval [a, b] up into n pieces, where n is even. Let
b−a
, xi = a + i∆x, and yi = f(xi ) for each i from 1 to n.
∆x =
n


The (n + 1)-point Simpson’s Rule approximation to
given by
Sn (f) =

n/2

∆x (
i=1

=

3

y2i + 4y2i+1 + y2i+2

b

a

f(x) dx is

)

)
b−a(
y0 + 4y1 + 2y2 + 4y3 + · · · + 2yn−2 + 4yn−1 + yn
3n

.

.

.

.

.

.

Meet the Simpsons

Thomas Simpson
(1710-1761)

Homer Simpson

.

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

.

x2 dx

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

x2 dx

Solution

So

} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44
(
)
1
4
9
16
1
0+4·
+2·
+4·
+
S 4 (f ) =
3·4
16
16
16 16
(
)
1 4 + 8 + 36 + 16
1 64
1
=
=
·
=
12
16
12 16
3

.

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

x2 dx

Solution

So

} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44
(
)
1
4
9
16
1
0+4·
+2·
+4·
+
S 4 (f ) =
3·4
16
16
16 16
(
)
1 4 + 8 + 36 + 16
1 64
1
=
=
·
=
12
16
12 16
3

No surprise we get the exact value; approximating a parabola
with a parabola should be exact!
.

.

.

.

.

.

Your turn

Example
Use Simpson’s Rule with n = 8 to estimate ln 2.

.

.

.

.

.

.

Your turn

Example
Use Simpson’s Rule with n = 8 to estimate ln 2.

Solution
0.693155

.

.

.

.

.

.

Section 5.7
Numerical Integration
Math 1a
Introduction to Calculus

April 25, 2008

Announcements


Midterm III is Wednesday 4/30 in class (covers §4.9–5.6)



Friday 5/2 is Movie Day!



Final (tentative) 5/23 9:15am



Problem Sessions Sunday, Thursday, 7pm, SC 310



.

.

.

.

.

.

Announcements



Midterm III is Wednesday 4/30 in class (covers §4.9–5.6)



Friday 5/2 is Movie Day!



Final (tentative) 5/23 9:15am



Problem Sessions Sunday, Thursday, 7pm, SC 310



Office hours Tues, Weds, 2–4pm SC 323

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Theorem (Integration by Parts)
Let u and v be differentiable functions. Then


u(x)v′ (x) dx = u(x)v(x) − v(x)u′ (x) dx.
Succinctly,



u dv = uv −



v du.

.

.

.

.

.

.

Theorem (Integration by Parts)
Let u and v be differentiable functions. Then


u(x)v′ (x) dx = u(x)v(x) − v(x)u′ (x) dx.
Succinctly,



u dv = uv −



v du.

Theorem (Integration by Parts, definite form)


a

b

¯b ∫
¯
u dv = uv¯¯ −
a

a

b

v du.

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Why estimate an integral when we have the FTC?









Antidifferentiation is
“hard”
Sometimes
antidifferentiation is
impossible
Sometimes all we need
is an approximation
These methods actually
work pretty well!

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )

In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )

In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

f(xi−1 ) + f(xi )
∆x
2

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

.xi



f(xi−1 ) + f(xi )
∆x
2

The smaller the
intervals, the better the
approximation
.

.

.

.

.

.

The Trapezoidal Rule
Definition
Divide the interval [a, b] up into n pieces. Let ∆x =
xi = a + i∆x, and yi = f(xi ) for each i from 1 to n.

b−a
,
n



The (n + 1)-point Trapezoidal Rule approximation to

a

is given by
Tn (f) =

n

f(xi−1 ) + f(xi )

2

i=1

b

f(x) dx

∆x

y
+ yn
y + y 1 y 1 + y2
+
+ · · · + n −1
= ∆x 0
2
2
2
)
∆x (
=
y0 + 2y1 + 2y2 + · · · + 2yn−1 + yn
2

[

.

.

.

]

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Trapezoidal Rule and n = 4.

.

.

.

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Trapezoidal Rule and n = 4.

Solution
The set of values is
} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44

So

(
)
1
1
4
9
16
Tn (f) =
0+2·
+2·
+2·
+
2·4
16
16
16 16
(
)
1 2 + 8 + 18 + 16
=
8
16
44
11
=
=
128
32
.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



1

2

1
dx
x

with the Trapezoidal Rule and n = 8.

.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



1

2

1
dx
x

with the Trapezoidal Rule and n = 8.

Solution
0.694122

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.

∆A =

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

.
.xi−1

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.
)
(
xi−1 + xi
∆x
∆A = f
2

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

.
.xi−1



.xi

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.
)
(
xi−1 + xi
∆x
∆A = f
2
Again, the smaller the
intervals, the better the
approximation

.

.

.

.

.

.

The Midpoint Rule
Definition

b−a
, and
n
xi = a + i∆x for each i from 1 to n.
∫ b
f(x) dx is
The (n + 1)-point Midpoint Rule approximation to
Divide the interval [a, b] up into n pieces. Let ∆x =

a

given by

(
)
n

xi−1 + xi
Mn (f) =
f
∆x
2
i=1
)
(
)
(
))
( (
x1 + x 2
xn−1 + xn
x0 + x1
+f
+ ··· + f
= ∆x f
2
2
2

.

.

.

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Midpoint Rule and n = 4.

.

.

.

.

.

.

Example
Example
Estimate



1

0

x2 dx with the Midpoint Rule and n = 4.

Solution
The set of midpoints is

{

So
Mn (f) =

0, 18 , 38 , 58 , 78

}

( )2 ( ) 2 ( )2 ( ) 2 )
1(
0 + 81 + 38 + 85 + 78
4
(
)
1 1 + 9 + 25 + 49
=
4
64
84
21
=
.
=
256
64
.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



2

1

1
dx
x

with the Midpoint Rule and n = 8.

.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



2

1

1
dx
x

with the Midpoint Rule and n = 8.

Solution
0.692661

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Parabolas instead of lines





.

Trapezoidal Rule
approximates the
function with a line
Why not use a parabola?
A section of a parabola
passing through equally
spaced points is

∆x
(y + 4y1 + y2 )
3 0


need an even number of
points

.

.

.

.

.

.

Simpson’s Rule
Definition
Divide the interval [a, b] up into n pieces, where n is even. Let
b−a
, xi = a + i∆x, and yi = f(xi ) for each i from 1 to n.
∆x =
n


The (n + 1)-point Simpson’s Rule approximation to
given by
Sn (f) =

n/2

∆x (
i=1

=

3

y2i + 4y2i+1 + y2i+2

b

a

f(x) dx is

)

)
b−a(
y0 + 4y1 + 2y2 + 4y3 + · · · + 2yn−2 + 4yn−1 + yn
3n

.

.

.

.

.

.

Meet the Simpsons

Thomas Simpson
(1710-1761)

Homer Simpson

.

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

.

x2 dx

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

x2 dx

Solution

So

} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44
(
)
1
4
9
16
1
0+4·
+2·
+4·
+
S 4 (f ) =
3·4
16
16
16 16
(
)
1 4 + 8 + 36 + 16
1 64
1
=
=
·
=
12
16
12 16
3

.

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

x2 dx

Solution

So

} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44
(
)
1
4
9
16
1
0+4·
+2·
+4·
+
S 4 (f ) =
3·4
16
16
16 16
(
)
1 4 + 8 + 36 + 16
1 64
1
=
=
·
=
12
16
12 16
3

No surprise we get the exact value; approximating a parabola
with a parabola should be exact!
.

.

.

.

.

.

Your turn

Example
Use Simpson’s Rule with n = 8 to estimate ln 2.

.

.

.

.

.

.

Your turn

Example
Use Simpson’s Rule with n = 8 to estimate ln 2.

Solution
0.693155

.

.

.

.

.

.

Section 5.7
Numerical Integration
Math 1a
Introduction to Calculus

April 25, 2008

Announcements


Midterm III is Wednesday 4/30 in class (covers §4.9–5.6)



Friday 5/2 is Movie Day!



Final (tentative) 5/23 9:15am



Problem Sessions Sunday, Thursday, 7pm, SC 310



.

.

.

.

.

.

Announcements



Midterm III is Wednesday 4/30 in class (covers §4.9–5.6)



Friday 5/2 is Movie Day!



Final (tentative) 5/23 9:15am



Problem Sessions Sunday, Thursday, 7pm, SC 310



Office hours Tues, Weds, 2–4pm SC 323

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Theorem (Integration by Parts)
Let u and v be differentiable functions. Then


u(x)v′ (x) dx = u(x)v(x) − v(x)u′ (x) dx.
Succinctly,



u dv = uv −



v du.

.

.

.

.

.

.

Theorem (Integration by Parts)
Let u and v be differentiable functions. Then


u(x)v′ (x) dx = u(x)v(x) − v(x)u′ (x) dx.
Succinctly,



u dv = uv −



v du.

Theorem (Integration by Parts, definite form)


a

b

¯b ∫
¯
u dv = uv¯¯ −
a

a

b

v du.

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Why estimate an integral when we have the FTC?









Antidifferentiation is
“hard”
Sometimes
antidifferentiation is
impossible
Sometimes all we need
is an approximation
These methods actually
work pretty well!

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )

In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )

In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

f(xi−1 ) + f(xi )
∆x
2

.xi

.

.

.

.

.

.

Trapezoids instead of rectangles


.f(xi−1 )
.f(xi )



In the case of a simple
decreasing function like
this one, clearly Ln is too
much and Rn is not
enough.
Why not average them
out and make a
trapezoid?

∆A =
.
.xi−1

.xi



f(xi−1 ) + f(xi )
∆x
2

The smaller the
intervals, the better the
approximation
.

.

.

.

.

.

The Trapezoidal Rule
Definition
Divide the interval [a, b] up into n pieces. Let ∆x =
xi = a + i∆x, and yi = f(xi ) for each i from 1 to n.

b−a
,
n



The (n + 1)-point Trapezoidal Rule approximation to

a

is given by
Tn (f) =

n

f(xi−1 ) + f(xi )

2

i=1

b

f(x) dx

∆x

y
+ yn
y + y 1 y 1 + y2
+
+ · · · + n −1
= ∆x 0
2
2
2
)
∆x (
=
y0 + 2y1 + 2y2 + · · · + 2yn−1 + yn
2

[

.

.

.

]

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Trapezoidal Rule and n = 4.

.

.

.

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Trapezoidal Rule and n = 4.

Solution
The set of values is
} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44

So

(
)
1
1
4
9
16
Tn (f) =
0+2·
+2·
+2·
+
2·4
16
16
16 16
(
)
1 2 + 8 + 18 + 16
=
8
16
44
11
=
=
128
32
.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



1

2

1
dx
x

with the Trapezoidal Rule and n = 8.

.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



1

2

1
dx
x

with the Trapezoidal Rule and n = 8.

Solution
0.694122

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )

The Trapezoidal Rule
averages the values

.f(xi )

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.

∆A =

.
.xi−1

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

.
.xi−1

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.
)
(
xi−1 + xi
∆x
∆A = f
2

.xi

.

.

.

.

.

.

Midpoints to cancel out the slop



.f(xi−1 )



.f(xi )

.
.xi−1



.xi

The Trapezoidal Rule
averages the values
Another possibility
would be to average the
points.
)
(
xi−1 + xi
∆x
∆A = f
2
Again, the smaller the
intervals, the better the
approximation

.

.

.

.

.

.

The Midpoint Rule
Definition

b−a
, and
n
xi = a + i∆x for each i from 1 to n.
∫ b
f(x) dx is
The (n + 1)-point Midpoint Rule approximation to
Divide the interval [a, b] up into n pieces. Let ∆x =

a

given by

(
)
n

xi−1 + xi
Mn (f) =
f
∆x
2
i=1
)
(
)
(
))
( (
x1 + x 2
xn−1 + xn
x0 + x1
+f
+ ··· + f
= ∆x f
2
2
2

.

.

.

.

.

.

Example
Example
Estimate



0

1

x2 dx with the Midpoint Rule and n = 4.

.

.

.

.

.

.

Example
Example
Estimate



1

0

x2 dx with the Midpoint Rule and n = 4.

Solution
The set of midpoints is

{

So
Mn (f) =

0, 18 , 38 , 58 , 78

}

( )2 ( ) 2 ( )2 ( ) 2 )
1(
0 + 81 + 38 + 85 + 78
4
(
)
1 1 + 9 + 25 + 49
=
4
64
84
21
=
.
=
256
64
.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



2

1

1
dx
x

with the Midpoint Rule and n = 8.

.

.

.

.

.

.

Your Turn

Example
Estimate
ln 2 =



2

1

1
dx
x

with the Midpoint Rule and n = 8.

Solution
0.692661

.

.

.

.

.

.

Outline
Last Time: Integration by Parts
The Trapezoidal Rule
Trapezoids instead of rectangles
The Midpoint Rule
Simpson’s Rule
Error estimates for the Trapezoidal and Midpoint Rules
Error estimates for Simpson’s Rule

.

.

.

.

.

.

Parabolas instead of lines





.

Trapezoidal Rule
approximates the
function with a line
Why not use a parabola?
A section of a parabola
passing through equally
spaced points is

∆x
(y + 4y1 + y2 )
3 0


need an even number of
points

.

.

.

.

.

.

Simpson’s Rule
Definition
Divide the interval [a, b] up into n pieces, where n is even. Let
b−a
, xi = a + i∆x, and yi = f(xi ) for each i from 1 to n.
∆x =
n


The (n + 1)-point Simpson’s Rule approximation to
given by
Sn (f) =

n/2

∆x (
i=1

=

3

y2i + 4y2i+1 + y2i+2

b

a

f(x) dx is

)

)
b−a(
y0 + 4y1 + 2y2 + 4y3 + · · · + 2yn−2 + 4yn−1 + yn
3n

.

.

.

.

.

.

Meet the Simpsons

Thomas Simpson
(1710-1761)

Homer Simpson

.

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

.

x2 dx

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

x2 dx

Solution

So

} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44
(
)
1
4
9
16
1
0+4·
+2·
+4·
+
S 4 (f ) =
3·4
16
16
16 16
(
)
1 4 + 8 + 36 + 16
1 64
1
=
=
·
=
12
16
12 16
3

.

.

.

.

.

.

Examples
Example
Use Simpson’s rule with n = 4 to estimate

1



0

x2 dx

Solution

So

} { ( ) 2 ( ) 2 ( ) 2 ( )2 }
{
y0 , y1 , y2 , y3 , y4 = 0, 41 , 42 , 34 , 44
(
)
1
4
9
16
1
0+4·
+2·
+4·
+
S 4 (f ) =
3·4
16
16
16 16
(
)
1 4 + 8 + 36 + 16
1 64
1
=
=
·
=
12
16
12 16
3

No surprise we get the exact value; approximating a parabola
with a parabola should be exact!
.

.

.

.

.

.

Your turn

Example
Use Simpson’s Rule with n = 8 to estimate ln 2.

.

.

.

.

.

.

Your turn

Example
Use Simpson’s Rule with n = 8 to estimate ln 2.

Solution
0.693155

.

.

.

.

.

.