166SCW, 7.7-Example 5: Error Bound Examples Involving Right Endpoint Sums and Left Endpoint Sums
166SCW, 7.7-Example 5: Error Bound Examples Involving Right Endpoint Sums and Left Endpoint Sums
Recall the Mathematica commands for approximation of f(x)x with or :
b
∫
a
L
n
R
n
In[]:=
LeftSum[f_,a_,b_,n_]:=f[a+(i-1)*(b-a)/n]*(b-a)/n
n
∑
i=1
In[]:=
RightSum[f_,a_,b_,n_]:=f[a+i*(b-a)/n]*(b-a)/n
n
∑
i=1
Let'slookatthedefiniteintegralx:
2
∫
-1
-
2
x
e
In[]:=
f[x_]:=E^(-x^2)
Plot[f[x],{x,-1,2}]
Out[]=
(a) First we estimate this definite integral with and :
R
10
R
100
N[RightSum[f,-1,2,10]]
Out[]=
1.5704
N[RightSum[f,-1,2,100]]
Out[]=
1.6236
(b) Equation (4) can be used to determine how well these estimates approximate the definite integral. To apply this error estimate, we need to bound |f ' (x)| on [-1,2]. Here are two ways to do this:
(i) Graphically:
(i) Graphically:
Plot[f'[x],{x,-1,2}]
Out[]=
Clearly,on[-1,2],|f'(x)|≤1,sotake=1inEquation(4).Thenitfollowsthat I-≤=0.45and I-≤=0.045.Notethatmultiplyingthenumberofrectanglesby10causedtheestimateinerrortodecreasebyafactorof1/10!!!WhatdoyouthinkwouldhappentotheerrorboundifweusedtoestimateI? (ii)UsingCalculus: On[-1,2],sincef'iscontinuous,itmustattainitsmaximumandminimumvalues.Thesewilloccurateitherendpointsorcriticalpointsoff'.
K
1
R
10
1*
2
(2+1)
2*10
R
100
1*
2
(2+1)
2*100
R
1000
f''[x]
Out[]=
-2+4
-
2
x
-
2
x
2
x
Solve[f''[x]==0,x]
Out[]=
x-,x
1
2
1
2
1./Sqrt[2]
Out[]=
0.707107
Since both solutions are in [-1,2], the places where |f '| can be maximized on [-1,2] are at x=-1, -1/, 1/, or x=2:
2
2
Abs[f'[{-1,-1/Sqrt[2],1/Sqrt[2],2}]]
Out[]=
,,,
2
2
2
4
4
N[%]
Out[]=
{0.735759,0.857764,0.857764,0.0732626}
Thus,wecantake=≤=0.52462and I-≤=0.052462
K
1
(2/E)
orabout0.857764.Thenitfollowsthat I-R
10
2/E
*2
(2+1)
2*10
R
100
(2/E)
*2
(2+1)
2*100
Using Mathematica, here is what we get numerically:
NIntegrate[E^(-x^2),{x,-1,2}]
Out[]=
1.62891
Compare to our estimates:
Abs[NIntegrate[E^(-x^2),{x,-1,2}]-RightSum[f,-1,2,10]]
Out[]=
0.0585105
Abs[NIntegrate[E^(-x^2),{x,-1,2}]-RightSum[f,-1,2,100]]
Out[]=
0.00530413