0% found this document useful (0 votes)
19 views56 pages

Lecture 6

The document discusses numerical integration methods, specifically focusing on composite rules such as the rectangular and trapezoidal rules. It outlines the problem setting, the construction of equally and unequally spaced points for approximation, and the formulas for calculating integrals using these methods. Additionally, it provides examples and discusses truncation errors associated with each method.

Uploaded by

iceyxi002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views56 pages

Lecture 6

The document discusses numerical integration methods, specifically focusing on composite rules such as the rectangular and trapezoidal rules. It outlines the problem setting, the construction of equally and unequally spaced points for approximation, and the formulas for calculating integrals using these methods. Additionally, it provides examples and discusses truncation errors associated with each method.

Uploaded by

iceyxi002
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

AMA 3201: Computational Methods

Subject Lecturer: Jianbo Cui

Lecture 6
Numerical integration
Composite rules

0 / 25
Problem Setting

Rb
Aim: Given f ∈ C[a, b], compute a
f (x)dx.

1 / 25
Problem Setting

Rb
Aim: Given f ∈ C[a, b], compute a
f (x)dx.
Rb P
Idea: Construct xi ∈ [a, b] and αi so that a
f (x)dx ≈ αi f (xi ).

1 / 25
Problem Setting

Rb
Aim: Given f ∈ C[a, b], compute a
f (x)dx.
Rb P
Idea: Construct xi ∈ [a, b] and αi so that a
f (x)dx ≈ αi f (xi ).

Two approaches:
• Equally spaced xi , based on interpolating polynomials.
Examples: rectangular rule, trapezoidal rule, Simpson’s ( 13 ) rule.
• Unequally spaced xi , based on osculating polynomials.
Example: Gaussian quadrature.

1 / 25
Rectangular Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi .

2 / 25
Rectangular Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi .


• On each [xi , xi+1 ], approximate f by the constant f ( xi +x2 i+1 ).

2 / 25
Rectangular Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi .


• On each [xi , xi+1 ], approximate f by the constant f ( xi +x2 i+1 ).
• (Composite rule) Sum the formula up for i = 0, . . . , n − 1.

2 / 25
Rectangular Rule

b−a
Formula: On each [xi , xi+1 ], write h = n = xi+1 − xi . We have
Z xi+1    
xi + xi+1 xi + xi+1
f dx = f h.
xi 2 2

3 / 25
Rectangular Rule

b−a
Formula: On each [xi , xi+1 ], write h = n = xi+1 − xi . We have
Z xi+1    
xi + xi+1 xi + xi+1
f dx = f h.
xi 2 2

Thus,
Z b n−1 Z xi+1   n−1  
X xi + xi+1 X xi + xi+1
f (x)dx ≈ f dx = f h.
a xi 2 2
i=0 i=0

3 / 25
Rectangular Rule

Truncation error: Assume that f ∈ C 2 [a, b].


xi +xi+1
On each [xi , xi+1 ], write ui := 2 . Then we have
Z xi+1 Z xi+1
[f (x) − f (ui )]dx = f [ui , x] (x − ui ) dx.
xi xi | {z }
changes sign

4 / 25
Rectangular Rule

Truncation error: Assume that f ∈ C 2 [a, b].


xi +xi+1
On each [xi , xi+1 ], write ui := 2 . Then we have
Z xi+1 Z xi+1
[f (x) − f (ui )]dx = f [ui , x] (x − ui ) dx.
xi xi | {z }
changes sign

Rx
Define r (x) := xi
(y − ui )dy. Then r (xi ) = 0 and
xi+1
1
r (xi+1 ) = (y − ui )2 = 0.
2 xi

Moreover, r ′ (x) is negative on (xi , ui ) and positive on (ui , xi+1 ) =⇒


max[xi ,xi+1 ] r (x) ≤ max{r (xi ), r (xi+1 )} = 0.

4 / 25
Rectangular Rule

Truncation error cont.: Hence, we have


Z xi+1 Z xi+1
f [ui , x](x − ui )dx = f [ui , x]r ′ (x)dx
xi xi
xi+1 Z xi+1
= r (x)f [ui , x] − f [ui , x, x]r (x)dx
xi xi
Z xi+1
= −f [ui , ξi , ξi ] r (x)dx for some ξi ∈ [xi , xi+1 ],
xi
Z xi+1
1
= − f [ui , ξi , ξi ] [(x − ui )2 − (xi − ui )2 ]dx
2 xi
h3 h3
=− f [ui , ξi , ξi ] = − f ′′ (µi ) for some µi ∈ [xi , xi+1 ].
12 24

5 / 25
Rectangular Rule

Truncation error cont.: Total truncation error is


n−1 Z
X xi+1
f [ui , x](x − ui )dx
i=0 xi

n−1 3 n−1
X h ′′ h3 1 X ′′
= f (µi ) = ·n· f (µi )
24 24 n
i=0 i=0
(b − a)h2 ′′
= |f (µ)|
24
for some µ ∈ [a, b].

6 / 25
Example

Example: Compute 02 sin x dx by the rectangular rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.011.

7 / 25
Example

Example: Compute 02 sin x dx by the rectangular rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.011.

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.

7 / 25
Example

Example: Compute 02 sin x dx by the rectangular rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.011.

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.
Z π         
2 π π 3π 5π 7π
sin x dx ≈ sin + sin + sin + sin
0 8 16 16 16 16
= 1.0065.

7 / 25
Example

Example: Compute 02 sin x dx by the rectangular rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.011.

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.
Z π         
2 π π 3π 5π 7π
sin x dx ≈ sin + sin + sin + sin
0 8 16 16 16 16
= 1.0065.

(b − a)h2 ′′
Error = |f (µ)| for some µ ∈ [0, π2 ],
24
π π 2
( )
≤ 2 8 ≈ 0.0101 < 0.011.
24

7 / 25
Trapezoidal Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi .

8 / 25
Trapezoidal Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi .


• On each [xi , xi+1 ], approximate f by the interpolating polynomial
p1 at xi and xi+1 .

8 / 25
Trapezoidal Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi .


• On each [xi , xi+1 ], approximate f by the interpolating polynomial
p1 at xi and xi+1 .
• (Composite rule) Sum the formula up for i = 0, . . . , n − 1.

8 / 25
Trapezoidal Rule
Formula: On each [xi , xi+1 ], write h = b−a n = xi+1 − xi . We have
Z xi+1 Z xi+1  
x − xi x − xi+1
p1 (x) dx = fi+1 + fi dx.
xi xi xi+1 − xi xi − xi+1
Z xi+1  
x − xi x − xi+1
= fi+1 − fi dx
xi h h
1   xi+1
= (x − xi )2 fi+1 − (x − xi+1 )2 fi
2h xi
   
1 2 fi+1 + f i fi+1 + fi
= (xi+1 − xi ) = h.
h 2 2

9 / 25
Trapezoidal Rule
Formula: On each [xi , xi+1 ], write h = b−a n = xi+1 − xi . We have
Z xi+1 Z xi+1  
x − xi x − xi+1
p1 (x) dx = fi+1 + fi dx.
xi xi xi+1 − xi xi − xi+1
Z xi+1  
x − xi x − xi+1
= fi+1 − fi dx
xi h h
1   xi+1
= (x − xi )2 fi+1 − (x − xi+1 )2 fi
2h xi
   
1 2 fi+1 + f i fi+1 + fi
= (xi+1 − xi ) = h.
h 2 2
Thus,
Z b n−1    
X fi+1 + fi f0 + fn
f (x)dx ≈ h= + f1 + f2 + · · · + fn−1 h.
a 2 2
i=0

9 / 25
Trapezoidal Rule
Truncation error: Assume that f ∈ C 2 [a, b].
On each [xi , xi+1 ], we have
Z xi+1 Z xi+1
[f (x) − p1 (x)]dx = f [xi , xi+1 , x] (x − xi )(x − xi+1 ) dx
xi xi | {z }
≤0
Z xi+1
= f [xi , xi+1 , ξi ] (x − xi )(x − xi+1 )dx for some ξi ∈ [xi , xi+1 ],
xi
Z xi+1
= f [xi , xi+1 , ξi ] (x − xi )(x − xi − h)dx
xi
Z xi+1
= f [xi , xi+1 , ξi ] [(x − xi )2 − (x − xi )h]dx
xi
h3 h3
=− f [xi , xi+1 , ξi ] = − f ′′ (νi ) for some νi ∈ [xi , xi+1 ].
6 12

10 / 25
Trapezoidal Rule
Truncation error cont.: Total truncation error is
n−1 Z
X xi+1
f [xi , xi+1 , x](x − xi )(x − xi+1 )dx
i=0 xi

n−1 3 n−1
X h ′′ h3 1 X ′′
= f (νi ) = ·n· f (νi )
12 12 n
i=0 i=0
2
(b − a)h ′′
= |f (ν)|
12
for some ν ∈ [a, b].

11 / 25
Trapezoidal Rule
Truncation error cont.: Total truncation error is
n−1 Z
X xi+1
f [xi , xi+1 , x](x − xi )(x − xi+1 )dx
i=0 xi

n−1 3 n−1
X h ′′ h3 1 X ′′
= f (νi ) = ·n· f (νi )
12 12 n
i=0 i=0
2
(b − a)h ′′
= |f (ν)|
12
for some ν ∈ [a, b].

Remark: Note that this error seems larger than that of rectangular
rule, which is counter-intuitive. However, note that the ν here and the
µ for the rectangular rule can be radically different: given that both
errors are in the order of h2 , this can have a big impact on the error.

11 / 25
Example

Example: Compute 02 sin x dx by the trapezoidal rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.021.

12 / 25
Example

Example: Compute 02 sin x dx by the trapezoidal rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.021.

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.

12 / 25
Example

Example: Compute 02 sin x dx by the trapezoidal rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.021.

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.
π
π sin 0 + sin π2
Z  
2 π π 3π
sin x dx ≈ + sin + sin + sin
0 8 2 8 4 8
= 0.9871.

12 / 25
Example

Example: Compute 02 sin x dx by the trapezoidal rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 0.021.

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.
π
π sin 0 + sin π2
Z  
2 π π 3π
sin x dx ≈ + sin + sin + sin
0 8 2 8 4 8
= 0.9871.

(b − a)h2 ′′
Error = |f (ν)| for some ν ∈ [0, π2 ]
12
π π 2
( )
≤ 2 8 ≈ 0.0202 < 0.021.
12

12 / 25
Simpson’s Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi . Note that n has to be even!

13 / 25
Simpson’s Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi . Note that n has to be even!


• On each [xi , xi+2 ], i even, approximate f by the interpolating
polynomial p2 at xi , xi+1 and xi+2 .

13 / 25
Simpson’s Rule

Idea:
• Partition [a, b] into

a =: x0 < x1 < · · · < xn−1 < xn := b

with equally spaced xi . Note that n has to be even!


• On each [xi , xi+2 ], i even, approximate f by the interpolating
polynomial p2 at xi , xi+1 and xi+2 .
• (Composite rule) Sum the formula up for i = 0, 2, 4, . . . , n − 2.

13 / 25
Simpson’s Rule

b−a
Formula: On each [xi , xi+2 ], i even, write h = n = xi+1 − xi .
Consider
(x − xi+1 )(x − xi+2 ) (x − xi )(x − xi+2 )
p2 (x) = fi + fi+1
(xi − xi+1 )(xi − xi+2 ) (xi+1 − xi )(xi+1 − xi+2 )
(x − xi )(x − xi+1 )
+ fi+2
(xi+2 − xi )(xi+2 − xi+1 )
(x − xi+1 )(x − xi+2 ) (x − xi )(x − xi+2 )
= fi + fi+1
2h2 −h2
(x − xi )(x − xi+1 )
+ fi+2 .
2h2
We integrate the three quadratics one by one on [xi , xi+2 ].

14 / 25
Simpson’s Rule

Formula cont.: Let x = xi+1 + sh for s ∈ [−1, 1]. Then we have


xi+2 Z 1
(x − xi+1 )(x − xi+2 ) s(s − 1)
Z
h
2
dx = h ds = ,
xi 2h −1 2 3
xi+2 Z 1
(x − xi )(x − xi+2 ) (s + 1)(s − 1)
Z
4h
dx = h ds = ,
xi −h2 −1 −1 3
xi+2 Z 1
(x − xi )(x − xi+1 )
Z
(s + 1)s h
dx = h ds = ,
xi 2h2 −1 2 3

Hence,
Z xi+2
h
p2 (x) dx = (fi + 4fi+1 + fi+2 ).
xi 3

15 / 25
Simpson’s Rule

Formula cont.: Thus, the integral is given approximately by


Z b
f (x) dx
a
h
≈ [(f0 + fn ) + 2(f2 + f4 + f6 + · · · + fn−2 ) + 4(f1 + f3 + · · · + fn−1 )].
3

16 / 25
Simpson’s Rule
Truncation error: Assume that f ∈ C 4 [a, b].

On each [xi , xi+2 ], i even, we have


Z xi+2 Z xi+2
[f (x)−p2 (x)]dx = f [xi , xi+1 , xi+2 , x] (x − xi )(x − xi+1 )(x − xi+2 ) dx.
xi xi | {z }
changes sign

17 / 25
Simpson’s Rule
Truncation error: Assume that f ∈ C 4 [a, b].

On each [xi , xi+2 ], i even, we have


Z xi+2 Z xi+2
[f (x)−p2 (x)]dx = f [xi , xi+1 , xi+2 , x] (x − xi )(x − xi+1 )(x − xi+2 ) dx.
xi xi | {z }
changes sign

Rx
Define r (x) := xi (y − xi )(y − xi+1 )(y − xi+2 )dy . Then r (xi ) = 0 and
(substituting y = xi+1 + sh)
Z 1
r (xi+2 ) = h4 (s + 1)s(s − 1)ds = 0.
−1

Moreover, r ′ (x) is positive on (xi , xi+1 ) and negative on (xi+1 , xi+2 )


=⇒ min[xi ,xi+2 ] r (x) ≥ min{r (xi ), r (xi+2 )} = 0.

17 / 25
Simpson’s Rule

Truncation error cont.: Hence, we have


Z xi+2
f [xi , xi+1 , xi+2 , x](x − xi )(x − xi+1 )(x − xi+2 )dx
xi
Z xi+2
= f [xi , xi+1 , xi+2 , x]r ′ (x)dx
xi
xi+2 Z xi+1
= r (x)f [xi , xi+1 , xi+2 , x] − f [xi , xi+1 , xi+2 , x, x]r (x)dx
xi xi
Z xi+2
= −f [xi , xi+1 , xi+2 , ζi , ζi ] r (x)dx for some ζi ∈ [xi , xi+2 ].
xi

18 / 25
Simpson’s Rule

Truncation error cont.: Next, observe that


Z xi+2
r (x)dx
xi
xi+2 Z xi+2
= (x − xi+1 )r (x) − r ′ (x)(x − xi+1 )dx
xi xi
Z xi+2
=− (x − xi )(x − xi+1 )2 (x − xi+2 )dx substitute x = xi+1 + sh
xi
Z 1 Z 1
= −h5 (s + 1)s2 (s − 1)ds = −h5 (s4 − s2 )ds
−1 −1
4h5
= .
15

19 / 25
Simpson’s Rule
Truncation error cont.: Consequently,
Z xi+2
f [xi , xi+1 , xi+2 , x](x − xi )(x − xi+1 )(x − xi+2 )dx
xi

4h5 4h5 f (4) (γi ) h5


=− f [xi , xi+1 , xi+2 , ζi , ζi ] = − · = − f (4) (γi ),
15 15 4! 90
for some γi ∈ [xi , xi+2 ].

20 / 25
Simpson’s Rule
Truncation error cont.: Consequently,
Z xi+2
f [xi , xi+1 , xi+2 , x](x − xi )(x − xi+1 )(x − xi+2 )dx
xi

4h5 4h5 f (4) (γi ) h5


=− f [xi , xi+1 , xi+2 , ζi , ζi ] = − · = − f (4) (γi ),
15 15 4! 90
for some γi ∈ [xi , xi+2 ].

Total truncation error is


h5 (4)
| f (γ0 ) + f (4) (γ2 ) + · · · + f (4) (γn−2 ) |
90 | {z }
n numbers
2

h5 n f (4) (γ0 ) + f (4) (γ2 ) + · · · + f (4) (γn−2 ) (b − a)h4 (4)


= · = |f (γ)|
90 2 n/2 180
for some γ ∈ [a, b].

20 / 25
Example 1

Example: Compute 02 sin x dx by the Simpson’s rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 3 × 10−4 .

21 / 25
Example 1

Example: Compute 02 sin x dx by the Simpson’s rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 3 × 10−4 .

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.

21 / 25
Example 1

Example: Compute 02 sin x dx by the Simpson’s rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 3 × 10−4 .

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.
Z π   
2 1 π π π π 3π
sin x dx ≈ · sin 0 + sin + 2 sin + 4 sin + sin
0 3 8 2 4 8 8
= 1.0001.

21 / 25
Example 1

Example: Compute 02 sin x dx by the Simpson’s rule using n = 4
and round your answer to the nearest 4 decimal places. Show that
the truncation error is at most 3 × 10−4 .

iπ π
Solution: Note that f (x) = sin x, xi = 8 for i = 0, . . . , 4, and h = 8.
Z π   
2 1 π π π π 3π
sin x dx ≈ · sin 0 + sin + 2 sin + 4 sin + sin
0 3 8 2 4 8 8
= 1.0001.

(b − a)h4 (4)
Error = |f (γ)| for some γ ∈ [0, π2 ],
180
π π 4
( )
≤ 2 8 ≈ 2.08 × 10−4 < 3 × 10−4 .
180

21 / 25
Example 2
R1 2
Example: Compute 0 e−x dx by Simpson’s rule so that the
truncation error is at most 10−4 . Round your answer to the nearest 4
decimal places.

22 / 25
Example 2
R1 2
Example: Compute 0 e−x dx by Simpson’s rule so that the
truncation error is at most 10−4 . Round your answer to the nearest 4
decimal places.
2
Solution: We compute up to the 4th derivative of f (x) = e−x .
2
f ′ (x) = −2xe−x ,
2
f ′′ (x) = (4x 2 − 2)e−x ,
2
f ′′′ (x) = (12x − 8x 3 )e−x ,
2
f (4) (x) = (12 − 48x 2 + 16x 4 )e−x .

22 / 25
Example 2
R1 2
Example: Compute 0 e−x dx by Simpson’s rule so that the
truncation error is at most 10−4 . Round your answer to the nearest 4
decimal places.
2
Solution: We compute up to the 4th derivative of f (x) = e−x .
2
f ′ (x) = −2xe−x ,
2
f ′′ (x) = (4x 2 − 2)e−x ,
2
f ′′′ (x) = (12x − 8x 3 )e−x ,
2
f (4) (x) = (12 − 48x 2 + 16x 4 )e−x .

Thus,
max |f (4) (x)| ≤ 76.
0≤x≤1

22 / 25
Example 2
R1 2
Example: Compute 0 e−x dx by Simpson’s rule so that the
truncation error is at most 10−4 . Round your answer to the nearest 4
decimal places.
2
Solution: We compute up to the 4th derivative of f (x) = e−x .
2
f ′ (x) = −2xe−x ,
2
f ′′ (x) = (4x 2 − 2)e−x ,
2
f ′′′ (x) = (12x − 8x 3 )e−x ,
2
f (4) (x) = (12 − 48x 2 + 16x 4 )e−x .

Thus,
max |f (4) (x)| ≤ 76.
0≤x≤1

One can also use the tighter bound max0≤x≤1 |f (4) (x)| ≤ 20 (Why?). The resulting h and integral are left as an exercise.

22 / 25
Example 2 cont.

Solution cont.: To force error ≤ 10−4 , it suffices to force


b−a 4
h max |f (4) (x)| ≤ 10−4 ,
180 0≤x≤1

which would be satisfied if


1 4
h · 76 ≤ 10−4 , which is guaranteed if h ≤ 0.1240.
180

23 / 25
Example 2 cont.

Solution cont.: To force error ≤ 10−4 , it suffices to force


b−a 4
h max |f (4) (x)| ≤ 10−4 ,
180 0≤x≤1

which would be satisfied if


1 4
h · 76 ≤ 10−4 , which is guaranteed if h ≤ 0.1240.
180
Choose n = 10 so that h = 0.1, xi = 0.1i for i = 0, . . . , 10. Then
Z 1 " 4 5
#
−x 2 0.1 −02 −12
X
−(0.2i)2
X
−(0.2i−0.1)2
e dx ≈ e + e +2 e +4 e = 0.7468.
0 3
i=1 i=1

23 / 25
Example 3
R1  
x2
Example: Compute 0
sin 2 + 1 dx by Simpson’s rule so that the
−4
truncation error is at most 10 . Round your answer to the nearest 4
decimal places.

24 / 25
Example 3
R1  
x2
Example: Compute 0
sin 2 + 1 dx by Simpson’s rule so that the
−4
truncation error is at most 10 . Round your answer to the nearest 4
decimal places.
 2 
Solution: We compute up to the 4th derivative of f (x) = sin x2 + 1 .
 2   2   2 
x x x
f ′ (x) = x cos + 1 , f ′′ (x) = cos + 1 − x 2 sin +1 ,
2 2 2
 2   2 
x x
f ′′′ (x) = −x 3 cos + 1 − 3x sin +1 ,
2 2
 2   2 
(4) 2 x 4 x
f (x) = −6x cos + 1 + (x − 3) sin +1 .
2 2

24 / 25
Example 3
R1  
x2
Example: Compute 0
sin 2 + 1 dx by Simpson’s rule so that the
−4
truncation error is at most 10 . Round your answer to the nearest 4
decimal places.
 2 
Solution: We compute up to the 4th derivative of f (x) = sin x2 + 1 .
 2   2   2 
x x x
f ′ (x) = x cos + 1 , f ′′ (x) = cos + 1 − x 2 sin +1 ,
2 2 2
 2   2 
x x
f ′′′ (x) = −x 3 cos + 1 − 3x sin +1 ,
2 2
 2   2 
(4) 2 x 4 x
f (x) = −6x cos + 1 + (x − 3) sin +1 .
2 2
Thus,
max |f (4) (x)| ≤ 10.
0≤x≤1

24 / 25
Example 3 cont.
Solution cont.: To force error ≤ 10−4 , it suffices to force
b−a 4
h max |f (4) (x)| ≤ 10−4 ,
180 0≤x≤1

which would be satisfied if


1 4
h · 10 ≤ 10−4 , which is guaranteed if h ≤ 0.2059.
180

25 / 25
Example 3 cont.
Solution cont.: To force error ≤ 10−4 , it suffices to force
b−a 4
h max |f (4) (x)| ≤ 10−4 ,
180 0≤x≤1

which would be satisfied if


1 4
h · 10 ≤ 10−4 , which is guaranteed if h ≤ 0.2059.
180
1 i
Choose 2n = 6so that h = 6 , xi = 6 for i = 0, . . . , 6. Then
R1
0
sin x2 + 1 dx ≈
  2   2 
1 0 1
sin + 1 + sin +1
18 2 2
2
! 3
!#
X ( 3i )2 X ( 2i−1
6 )
2
+2 sin +1 +4 sin +1 = 0.9091.
2 2
i=1 i=1

25 / 25

You might also like