lesson 31: numerical integration
DESCRIPTION
Three methods for approximating an integral are surprisingly good: The Trapezoidal Rule, the Midpoint Rule, and Simpson's Rule.TRANSCRIPT
. . . . . .
Section5.7NumericalIntegration
Math1aIntroductiontoCalculus
April25, 2008
Announcements
◮ MidtermIII isWednesday4/30inclass(covers§4.9–5.6)◮ Friday5/2isMovieDay!◮ Final(tentative)5/239:15am◮ ProblemSessionsSunday, Thursday, 7pm, SC 310◮ OfficehoursTues, Weds, 2–4pmSC 323
. . . . . .
Announcements
◮ MidtermIII isWednesday4/30inclass(covers§4.9–5.6)◮ Friday5/2isMovieDay!◮ Final(tentative)5/239:15am◮ ProblemSessionsSunday, Thursday, 7pm, SC 310◮ OfficehoursTues, Weds, 2–4pmSC 323
. . . . . .
Outline
LastTime: IntegrationbyParts
TheTrapezoidalRuleTrapezoidsinsteadofrectangles
TheMidpointRule
Simpson’sRule
ErrorestimatesfortheTrapezoidalandMidpointRules
ErrorestimatesforSimpson’sRule
. . . . . .
Theorem(IntegrationbyParts)Let u and v bedifferentiablefunctions. Then∫
u(x)v′(x)dx = u(x)v(x) −∫
v(x)u′(x)dx.
Succinctly, ∫udv = uv−
∫v du.
Theorem(IntegrationbyParts, definiteform)
∫ b
audv = uv
∣∣∣∣ba−
∫ b
av du.
. . . . . .
Theorem(IntegrationbyParts)Let u and v bedifferentiablefunctions. Then∫
u(x)v′(x)dx = u(x)v(x) −∫
v(x)u′(x)dx.
Succinctly, ∫udv = uv−
∫v du.
Theorem(IntegrationbyParts, definiteform)
∫ b
audv = uv
∣∣∣∣ba−
∫ b
av du.
. . . . . .
Outline
LastTime: IntegrationbyParts
TheTrapezoidalRuleTrapezoidsinsteadofrectangles
TheMidpointRule
Simpson’sRule
ErrorestimatesfortheTrapezoidalandMidpointRules
ErrorestimatesforSimpson’sRule
. . . . . .
WhyestimateanintegralwhenwehavetheFTC?
◮ Antidifferentiationis“hard”
◮ Sometimesantidifferentiationisimpossible
◮ Sometimesallweneedisanapproximation
◮ Thesemethodsactuallyworkprettywell!
. . . . . .
Trapezoidsinsteadofrectangles
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ Inthecaseofasimpledecreasingfunctionlikethisone, clearly Ln istoomuchand Rn isnotenough.
◮ Whynotaveragethemoutandmakeatrapezoid?
∆A =
f(xi−1) + f(xi)2
∆x
◮ Thesmallertheintervals, thebettertheapproximation
. . . . . .
Trapezoidsinsteadofrectangles
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ Inthecaseofasimpledecreasingfunctionlikethisone, clearly Ln istoomuchand Rn isnotenough.
◮ Whynotaveragethemoutandmakeatrapezoid?
∆A =
f(xi−1) + f(xi)2
∆x
◮ Thesmallertheintervals, thebettertheapproximation
. . . . . .
Trapezoidsinsteadofrectangles
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ Inthecaseofasimpledecreasingfunctionlikethisone, clearly Ln istoomuchand Rn isnotenough.
◮ Whynotaveragethemoutandmakeatrapezoid?
∆A =
f(xi−1) + f(xi)2
∆x
◮ Thesmallertheintervals, thebettertheapproximation
. . . . . .
Trapezoidsinsteadofrectangles
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ Inthecaseofasimpledecreasingfunctionlikethisone, clearly Ln istoomuchand Rn isnotenough.
◮ Whynotaveragethemoutandmakeatrapezoid?
∆A =f(xi−1) + f(xi)
2∆x
◮ Thesmallertheintervals, thebettertheapproximation
. . . . . .
Trapezoidsinsteadofrectangles
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ Inthecaseofasimpledecreasingfunctionlikethisone, clearly Ln istoomuchand Rn isnotenough.
◮ Whynotaveragethemoutandmakeatrapezoid?
∆A =f(xi−1) + f(xi)
2∆x
◮ Thesmallertheintervals, thebettertheapproximation
. . . . . .
TheTrapezoidalRule
DefinitionDividetheinterval [a,b] upinto n pieces. Let ∆x =
b− an
,
xi = a + i∆x, and yi = f(xi) foreach i from 1 to n.
The (n + 1)-point TrapezoidalRule approximationto∫ b
af(x)dx
isgivenby
Tn(f) =n∑i=1
f(xi−1) + f(xi)2
∆x
= ∆x[y0 + y1
2+
y1 + y22
+ · · · +yn−1 + yn
2
]=
∆x2
(y0 + 2y1 + 2y2 + · · · + 2yn−1 + yn
)
. . . . . .
Example
Example
Estimate∫ 1
0x2 dx withtheTrapezoidalRuleand n = 4.
SolutionThesetofvaluesis{
y0, y1, y2, y3, y4}
={0,
(14
)2,(24
)2,(34
)2,(44
)2}So
Tn(f) =1
2 · 4
(0 + 2 · 1
16+ 2 · 4
16+ 2 · 9
16+
1616
)=
18
(2 + 8 + 18 + 16
16
)=
44128
=1132
. . . . . .
Example
Example
Estimate∫ 1
0x2 dx withtheTrapezoidalRuleand n = 4.
SolutionThesetofvaluesis{
y0, y1, y2, y3, y4}
={0,
(14
)2,(24
)2,(34
)2,(44
)2}So
Tn(f) =1
2 · 4
(0 + 2 · 1
16+ 2 · 4
16+ 2 · 9
16+
1616
)=
18
(2 + 8 + 18 + 16
16
)=
44128
=1132
. . . . . .
YourTurn
ExampleEstimate
ln 2 =
∫ 2
1
1xdx
withtheTrapezoidalRuleand n = 8.
Solution0.694122
. . . . . .
YourTurn
ExampleEstimate
ln 2 =
∫ 2
1
1xdx
withtheTrapezoidalRuleand n = 8.
Solution0.694122
. . . . . .
Outline
LastTime: IntegrationbyParts
TheTrapezoidalRuleTrapezoidsinsteadofrectangles
TheMidpointRule
Simpson’sRule
ErrorestimatesfortheTrapezoidalandMidpointRules
ErrorestimatesforSimpson’sRule
. . . . . .
Midpointstocancelouttheslop
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ TheTrapezoidalRuleaveragesthevalues
◮ Anotherpossibilitywouldbetoaveragethepoints.
∆A =
f(xi−1 + xi
2
)∆x
◮ Again, thesmallertheintervals, thebettertheapproximation
. . . . . .
Midpointstocancelouttheslop
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ TheTrapezoidalRuleaveragesthevalues
◮ Anotherpossibilitywouldbetoaveragethepoints.
∆A =
f(xi−1 + xi
2
)∆x
◮ Again, thesmallertheintervals, thebettertheapproximation
. . . . . .
Midpointstocancelouttheslop
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ TheTrapezoidalRuleaveragesthevalues
◮ Anotherpossibilitywouldbetoaveragethepoints.
∆A =
f(xi−1 + xi
2
)∆x
◮ Again, thesmallertheintervals, thebettertheapproximation
. . . . . .
Midpointstocancelouttheslop
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ TheTrapezoidalRuleaveragesthevalues
◮ Anotherpossibilitywouldbetoaveragethepoints.
∆A =
f(xi−1 + xi
2
)∆x
◮ Again, thesmallertheintervals, thebettertheapproximation
. . . . . .
Midpointstocancelouttheslop
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ TheTrapezoidalRuleaveragesthevalues
◮ Anotherpossibilitywouldbetoaveragethepoints.
∆A = f(xi−1 + xi
2
)∆x
◮ Again, thesmallertheintervals, thebettertheapproximation
. . . . . .
Midpointstocancelouttheslop
..xi−1 .xi
.f(xi−1)
.f(xi)
◮ TheTrapezoidalRuleaveragesthevalues
◮ Anotherpossibilitywouldbetoaveragethepoints.
∆A = f(xi−1 + xi
2
)∆x
◮ Again, thesmallertheintervals, thebettertheapproximation
. . . . . .
TheMidpointRule
DefinitionDividetheinterval [a,b] upinto n pieces. Let ∆x =
b− an
, and
xi = a + i∆x foreach i from 1 to n.
The (n + 1)-point MidpointRule approximationto∫ b
af(x)dx is
givenby
Mn(f) =n∑i=1
f(xi−1 + xi
2
)∆x
= ∆x(f(x0 + x1
2
)+ f
(x1 + x2
2
)+ · · · + f
(xn−1 + xn
2
))
. . . . . .
Example
Example
Estimate∫ 1
0x2 dx withtheMidpointRuleand n = 4.
SolutionThesetofmidpointsis {
0, 18 ,38 ,
58 ,
78
}So
Mn(f) =14
(0 +
(18
)2+
(38
)2+
(58
)2+
(78
)2)=
14
(1 + 9 + 25 + 49
64
)=
84256
=2164
.
. . . . . .
Example
Example
Estimate∫ 1
0x2 dx withtheMidpointRuleand n = 4.
SolutionThesetofmidpointsis {
0, 18 ,38 ,
58 ,
78
}So
Mn(f) =14
(0 +
(18
)2+
(38
)2+
(58
)2+
(78
)2)=
14
(1 + 9 + 25 + 49
64
)=
84256
=2164
.
. . . . . .
YourTurn
ExampleEstimate
ln 2 =
∫ 2
1
1xdx
withtheMidpointRuleand n = 8.
Solution0.692661
. . . . . .
YourTurn
ExampleEstimate
ln 2 =
∫ 2
1
1xdx
withtheMidpointRuleand n = 8.
Solution0.692661
. . . . . .
Outline
LastTime: IntegrationbyParts
TheTrapezoidalRuleTrapezoidsinsteadofrectangles
TheMidpointRule
Simpson’sRule
ErrorestimatesfortheTrapezoidalandMidpointRules
ErrorestimatesforSimpson’sRule
. . . . . .
Parabolasinsteadoflines
.
◮ TrapezoidalRuleapproximatesthefunctionwithaline
◮ Whynotuseaparabola?◮ A sectionofaparabolapassingthroughequallyspacedpointsis
∆x3
(y0 + 4y1 + y2)
◮ needanevennumberofpoints
. . . . . .
Simpson’sRule
DefinitionDividetheinterval [a,b] upinto n pieces, where n iseven. Let
∆x =b− an
, xi = a + i∆x, and yi = f(xi) foreach i from 1 to n.
The (n + 1)-point Simpson’sRule approximationto∫ b
af(x)dx is
givenby
Sn(f) =
n/2∑i=1
∆x3
(y2i + 4y2i+1 + y2i+2
)=
b− a3n
(y0 + 4y1 + 2y2 + 4y3 + · · · + 2yn−2 + 4yn−1 + yn
)
. . . . . .
MeettheSimpsons
ThomasSimpson(1710-1761)
HomerSimpson
. . . . . .
Examples
Example
UseSimpson’srulewith n = 4 toestimate∫ 1
0x2 dx
Solution{y0, y1, y2, y3, y4
}=
{0,
(14
)2,(24
)2,(34
)2,(44
)2}So
S4(f) =1
3 · 4
(0 + 4 · 1
16+ 2 · 4
16+ 4 · 9
16+
1616
)=
112
(4 + 8 + 36 + 16
16
)=
112
· 6416
=13
Nosurprisewegettheexactvalue; approximatingaparabolawithaparabolashouldbeexact!
. . . . . .
Examples
Example
UseSimpson’srulewith n = 4 toestimate∫ 1
0x2 dx
Solution{y0, y1, y2, y3, y4
}=
{0,
(14
)2,(24
)2,(34
)2,(44
)2}So
S4(f) =1
3 · 4
(0 + 4 · 1
16+ 2 · 4
16+ 4 · 9
16+
1616
)=
112
(4 + 8 + 36 + 16
16
)=
112
· 6416
=13
Nosurprisewegettheexactvalue; approximatingaparabolawithaparabolashouldbeexact!
. . . . . .
Examples
Example
UseSimpson’srulewith n = 4 toestimate∫ 1
0x2 dx
Solution{y0, y1, y2, y3, y4
}=
{0,
(14
)2,(24
)2,(34
)2,(44
)2}So
S4(f) =1
3 · 4
(0 + 4 · 1
16+ 2 · 4
16+ 4 · 9
16+
1616
)=
112
(4 + 8 + 36 + 16
16
)=
112
· 6416
=13
Nosurprisewegettheexactvalue; approximatingaparabolawithaparabolashouldbeexact!
. . . . . .
Yourturn
ExampleUseSimpson’sRulewith n = 8 toestimate ln 2.
Solution0.693155
. . . . . .
Yourturn
ExampleUseSimpson’sRulewith n = 8 toestimate ln 2.
Solution0.693155