You are on page 1of 18

lOMoARcPSD|12841845

M575 Chapter 10

Introduction To Numerical Analysis (Universiti Teknologi MARA)

StuDocu is not sponsored or endorsed by any college or university


Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)
lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Chapter 10

Trapezoidal
Rule
At the end of this chapter, students should be able to:
 Derive trapezoidal rule
 Identify and apply trapezoidal rule
 Determine error involved in trapezoidal rule

10.1 Introduction
From calculus books it is stated that the area under the graph for a given
function f(x) can be computed by evaluating definite integral, i.e.
b
Area   f ( x ) dx
a

There are other problems involving integration such as finding volume and arc
length.
b b
Volume   xf( x ) dx or Arc length   1  f ' ( x )2 dx
a a

b
The definite integral  f ( x ) dx can be computed once the function whose
a

differential; f(x) is determined. Unfortunately, this is not always possible


because
(a) it may not be possible to express the result of integration in terms of
known elementary functions such as

151

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

1 2 b cos x
x
e dx  dx
0 and a x

(b) numerical integration may be easier or quicker than calculating from the
function obtained by formal integration; or
(c) no analytical expression for the function to be integrated may be available
since the available information is being restricted to tabulated values.
b
However, the definite integral  f ( x ) dx is a number which represents the area
a

between y = f(x), the x-axis and the ordinates x = a and x = b. So, even if
b b
 f ( x ) dx cannot be found, an approximate value for  f ( x ) dx can be found by
a a

evaluating appropriate area using one of the numerical methods to be


discussed in this chapter.

y = f(x)

b
 f ( x ) dx
a

x
a b
Figure 10.1:

 Trapezoidal rule
 Simpson’s rule
 Simpson’s 3/8 rule

10.2 Trapezoidal Rule


For definite integrals which fall into the criteria mentioned above then a
numerical method can be used to approximate the value of these integrals.
One of the numerical methods is known as trapezoidal rule. Before we moved
further let’s define the term ‘trapezoid’.

152

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Definition
A trapezoid (trapezium) is a quadrilateral with one pair of opposite sides
parallel.

y0 y1
h

Figure 10.2: A trapezoid

The area of a trapezoid is


1
T (sums of parallel sides)(distance betw een them)
2
1
 ( y0  y1)h
2
b
Let’s consider the definite integral  f ( x ) dx assuming that f(x) is continuous
a

on [a, b].

y
y1
y2
y0
y3

y4

h h h h
x
a b
Figure 10.3:

b
If the area represented by  f ( x ) dx is divided into 4 smaller subintervals, each
a

of equal width h as shown in Figure 10.1, then each subinterval is


approximately a trapezoid.

Using the sum of the areas of these subintervals as an approximation for the
actual value of the area we have

153

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

b
 f ( x ) dx  A 1  A 2  A 3  A 4
a

1 1
where A1  ( f0  f1)h i.e. An  (fn-1  fn )h
2 2
Therefore,
b
 f ( x ) dx  A 1  A 2  A 3  A 4
a

1 1 1 1
 ( f0  f1)h  ( f1  f2 )h  (f2  f3 )h  ( f3  f4 )h
2 2 2 2
h
 (f0  2f1  2f2  2f3  f4 )
2
This method is known as the trapezoidal rule. The number of subintervals
(strips) used above is four and the number of ordinates (subscripts of y) is
five.
Note that the above subintervals must be evenly spaced. Generally, with
(n–1) number of subintervals or n number of ordinates, the trapezoidal rule is

b h
 f ( x ) dx  ( f0  2f1  2f2  ...  2fn -1  fn )
a 2

Steps – Trapezoidal Rule


 Identify the interval; [a, b]
 Identify the step size or number of subintervals; h, n
 Identify the function/data; f(x)
 Apply the trapezoidal rule
h n -1
T  ( f0  2  fi  fn )
2 i 1

Example 1
3
Use the trapezoidal rule with four subintervals to evaluate  x 2 dx .
1

154

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Solution x^2

10

5 x^2

0
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3

 Identify the interval; [a, b]


[1, 3]
 Identify the step size or number of subintervals; h or n
n4
and
ba
h
n
3 1
  0.5
4
 Identify the function f(x)

f ( x)  x2
 Apply the trapezoidal rule

i xi yi = xi2 coef coef*yi


0 x0 = 1.00 y0 = 1.00 1 1
1 x1 = 1.50 y1 = 2.25 2 4.5
2 x2 = 2.00 y2 = 4.00 2 8
3 x3 = 2.50 y3 = 6.25 2 12.50
4 x4 = 3.00 y4 = 9.00 1 9
3
2
 x dx T 8.75
1

h n-1
T ( y 0  2  yi  y n )
2 i1

0.5 3
T  ( y 0  2  yi  y 4 )
2 i1
 0.251  2(2.25  4  6.25 )  9 
 8.75

155

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Example 2
0 .8 2
Evaluate  e x dx with h = 0.2 by applying trapezoidal rule.
0

Solution

 Identify the interval; [a, b]


[0, 0.8]
 Identify the step size or number of subintervals; h or n
h  0.2
and
ba
n
h
0.8  0
 4
0.2
 Identify the function
2
f ( x)  ex
 Apply the trapezoidal rule
0 .8 h
f0  2f1  2f2  2f3  f4 
2
x
 e dx 
0 2


0.2
1.00  2(1.0408  1.1735  1.4333 )  1.8965 
2
 1.0192
2
i xi f(xi) = e x i coef coef*yi
0 0.00 1.0000 1 1.0000
1 0.20 1.0408 2 2.0816
2 0.40 1.1735 2 2.3470
3 0.60 1.4333 2 2.8667
4 0.80 1.8965 1 1.8965

This is an example where it is not possible to express the result of integration


in terms of known elementary function.

156

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Example 3
The following points were found empirically.
x 2.1 2.4 2.7 3.0 3.3 3.6 3.9
y 2.5 2.8 3.0 3.3 3.6 3.9 4.1
3 .9
Use the trapezoidal rule to estimate  y dx .
2.1

Solution

Note that the interval is [2.1, 3.9] while the step size; h = 0.3 and the
number of ordinates are 7. Therefore,
3.9
 y dx 
0.3
2.5  22.8  3.0  3.3  3.6  3.9  4.1
2.1 2
 5.97

Warm up exercise

2 1
Consider the definite integral  dx and divide the interval into 5
0 1  cos x

subintervals.
(i) Identify the interval.
(ii) Identify the step size.
(iii) Identify the function.
(iv) Approximate the definite integral above using trapezoidal rule with 6
ordinates.

As stated earlier trapezoidal rule is just an approximation to definite integral.


Hence, in order to determine the accuracy of the approximation it will be
necessary to look into its error analysis.

157

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

10.3 Error Analysis


b
Since trapezoidal rule is just an estimate to  f ( x ) dx , then the question is how
a

accurate is the approximation. Now let’s analyze the error incurred in using
b
the trapezoidal rule to estimate  f ( x ) dx .
a

Error in Trapezoidal Rule Approximations

An estimate for the local truncation error of a single application of the


trapezoidal rule is given by
1
Ea   f ' ' ( )(b  a)3
12
where  lies somewhere in the interval from a to b and f ' ' ( ) is the average
value of the second derivative which can be computed using
b
 f ' ' ( x ) dx
f ' ' ( )  a
ba
The computed error is only an approximation, since the average second
derivative is not necessarily an accurate approximation of f ' ' ( ) .
On the other hand, an error for the multiple-application trapezoidal rule can be
obtained by summing the individual errors for each segment to give
n
( b  a )3
Ea  
12n 3 i 1
 f ' ' ( i )  (1)

where f ' ' ( i ) is the second derivative at a point  i located in segment i. This
result can be simplified by estimating the mean or average value of the
second derivative for the entire interval as
n
 f ' ' ( i )
f ' '  i 1
n
n
Therefore nf ' '   f ' ' ( i ) and equation (1) can be written as
i 1

( b  a )3
Ea   f ' ' ( )
12n 2

158

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Same as before, the computed error is an approximate error since the mean
or average value of the second derivative was used.

Theorem

Suppose that f '' ( x ) exists on [a ,b]. Then for n a positive integer,


b
 f ( x ) dx  Tn  En
a
where
h n-1
Tn  ( f ( x0 )  2  f(xi )  f(xn )
2 i1
and the error En is given by
(b  a)3
En   f ' ' ( )
12n2
for some point  in [a, b].

Since the number  is not specified in this theorem, we are unable to use this
to determine the exact value of En for functions f(x) in general.

Steps – Error Analysis


 Identify the interval; [a, b]
 Identify the given information; Ea , h, n
 Identify the function; f(x)
 Find the second derivatives; f ' ' ( x )
 Compute the average value of the second derivatives;
b
 f ' ' ( x ) dx
f ' ' ( )  a
ba
 Compute the approximate error;
(b  a)3
Ea   f ' ' ( )
12n 2

Example 4
2
If the trapezoidal rule is used to compute  2 sin x dx then use the error
0
formula to estimate the error incurred if 10 subintervals are used.

159

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Solution

 Identify the interval; [a, b]


[0, 2]
 Identify the given information.
n = 10
 Identify the function
f ( x)  2 sin x

 Compute the second derivatives; f ' ' ( x )

f ' ( x )  2 cos x
f ' ' x   2 sin x
 Compute the average value of the second derivatives;
b
 f ' ' ( x ) dx
f ' ' ( )  a
ba
2
  2 sin x dx
f ' ' ( )  0
2

1
2 cos x 02
2
 cos 2  cos 0
 1.4161
 Compute the approximate error;

(b  a)3
Ea  f ' ' ( )
 12n2
(2  0)3
 1.4161
12(10 )2
 9.4407 x 10 3
 0.0944 x 10 1

Hence, if trapezoid rule with 10 subintervals is used to approximate


2
 2 sin x dx , then the approximation is accurate only to one decimal place.
0

160

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Example 5
1 2
If the trapezoid rule is to be used to compute  e  x dx with an error of at
0
most 0.0005, how many points or nodes are required?

Solution

2
The interval is [0, 1] with Ea  0.0005 and f ( x )  e x . Then
2 2
f ' ( x)  e x ( 2x)  2xe x
2 2
f '' ( x)  2e x  4x2e x
Hence, the average value of the second derivatives is
1
  2xe x 2 
f ' ' ( )   
 1 0 
 0

 2(1)e 1    2(0)e 0 
2 2

 
 0.7358

Therefore, if Ea  0.0005 then

b  a3 f ''  0.0005


 12n2

1  03  0.7358   0.0005


 12n2
0.0613
 0.0005
n2
0.0613
n
0.0005
n  11.0725

In order to achieve the required accuracy, the trapezoid rule requires at


least 12 subintervals or 13 nodes.

161

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Example 6
0.4
Assume  1  x 2 dx is being estimated by trapezoid rule.
0

a) Use the error formula to estimate the accuracy if 8 subintervals


are used.
b) Determine the number of points needed to estimate the integral
accurate to 3 decimal places?

Solution
Note that the interval is [0, 0.4] with f ( x )  1  x2 then

 
1
2 2
f ( x)  1 x

x
f ' (x) 
1  x2

1 x2
f '' ( x)  
3
1 x2  1 x2 
 
 
Hence
0 .4
'' 1  x 
f (x)   
0.4  1  x 2 
 0
1   0 .4 
  0
0.4  0.9165 
 1.0911
(a) If 8 subintervals are used then the error incur is

(b  a)3
Ea  f ' ' ()
 12n 2
( 0 .4  0 ) 3
 1.0911
12(8)2
 9.0925 x 10  5
 0.0909 x 10  3
The estimation is accurate up to 3 decimal places.

162

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

(b) To achieve the accuracy of Ea  0.5 x 103 the required subintervals


are

b  a3 f ''  0.0005


 12n2
0.4  03  1.0911  0.0005
 12n 2
0.0058
 0.0005
n2
0.0058
n
0.0005
n  3.41
Hence, at least 5 points are needed to achieve the accuracy of

Ea  0.5 x 103 .

Instead of approximating the error by using the average of the second


derivatives another way is to look for a bound on the error.

Theorem

If f '' ( x ) is continuous in [a, b], then the error in the trapezoid rule is no larger
than

b  a3 f '' (M) ,


2
12n

where f '' (M) is the largest value of f '' ( x ) in [a, b].

163

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

Warm up exercise
3
Assume  ln x dx is being estimated by trapezoid rule with 5 subintervals.
1

(i) Identify the interval and the step size.

(ii) Determine f(x), f '' ( x ) and f '' ( x ) .


(iii) Compute the approximated error.

Exercise 10

1. Use the trapezoidal rule to estimate the following definite integral with n
subintervals.

2 1 1 .6
x
(a)  dx ;n = 4 (d)  xe dx ; n = 6
0 1  cos x 1

20 x 3
(b)  dx ; n = 10 (e)  2 ln x dx ; n =8
0 5 1

 sin t 2
(c)  dt ;n=9 (f)  2x cos x dx ; n = 10
 t 0

2. The table indicates a relationship between two variables x and y.


x 1.2 1.3 1.4 1.5 1.6 1.7
y 1.94 2.19 2.46 2.75 3.06 3.39
1 .7
Assume y = f(x) where f is continuous, and approximate  f ( x ) dx using the
1 .2
trapezoidal rule.

3. Refer to question (1), use the error estimate formula to approximate the error
if the given integral is approximated by trapezoidal rule with the given
subintervals, n.
4. The arc length of the curve y = f(x) over the interval a  x  b is

b
length   1  ( f ' ( x ))2 dx
a

164

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

(a) Approximate the arc length of each function using trapezoidal rule with
n = 10.
(b) Approximate the error accuracy.
(c) How many ordinates are needed to estimate the integral with an accuracy
of 0.5 x 10 3 .

(i) f ( x)  x3 for 0  x  1


(ii) f ( x )  sin 2x for 0  x 
8

(iii) f ( x)  e2x for 0  x  0.5

5. Use the trapezoidal rule with n = 5 to estimate the area of the region under
the curve m( t )  50  2t 2 and above the t-axis.

(a) What is the exact area of this region?


(b) What is the smallest n that results in the value of this estimate?

6. Volume of Water in a Swimming Pool A rectangular swimming pool is 30 ft


wide and 50 ft long. The table below shows the depth h(x) of the water at 5-ft
intervals from one end of the pool to the other. Estimate the volume of water
in the pool using Trapezoidal Rule with n=10, applied to the integral
50
V=  30  h( x)dx .
0

Position (ft) Depth (ft) Position(ft) Depth (ft)


x h(x) x h(x)_ __
0 6.0 30 11.5
5 8.2 35 11.9
10 9.1 40 12.3
15 9.9 45 12.7
20 10.5 50 13.0
25 11.0

7. Stocking a Fish Pond As the fish and game warden of your township, you are
responsible for stocking the town pond with fish before the fishing season.
The average depth of the pond is 20 feet. Using the scaled map, you
measure distances across the pond at 200-foot intervals, as shown in the
diagram.

(a) Use the Trapezoidal Rule to estimate the volume of the pond.
(b) You plan to start the season with one fish per 100 cubic feet. You intend to
have at least 25% of the opening day’ fish population left at the end of the

165

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

season. What is the maximum number of licenses the town can ell in the
average seasonal catch is 20 fish per license?

166

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)


lOMoARcPSD|12841845

Part 6 NUMERICAL INTEGRATION MAT 575

http://www.math.dartmouth.edu/~calcsite/video1.html#406
Source: 1999 Addison Wesley Longman, Inc.
http://www.mathcs.emory.edu/ccs/ccs215/integral/node3.html

167

Downloaded by RAJA FARHATUL AIESYA RAJA AZHAR (2020859442@student.uitm.edu.my)

You might also like