TRAPEZOIDAL RULE OF INTEGRATION

AN INTERACTIVE EBOOK

 

On non Internet Explorer browsers, the equations may not show up.

As an alternative or if you prefer,

you can see the pdf version of the ebook instead

 

Title

An interactive e-book for illustrating the Trapezoidal Rule for numerical integration.

Creator

Autar K Kaw

Subject and Keywords

Trapezoidal Rule, Numerical Integration, Mathcad, Maple, Mathematica, Matlab, Simulations.

Description

This is an interactive E-book for illustrating Trapezoidal rule.  It includes links to simulations in Mathcad, Maple, Mathematica and Matlab for the algorithm, multiple choice quizzes, problem set, and a PowerPoint presentation.

Publisher

Holistic Numerical Methods Institute,

College of Engineering,

University of South Florida, Tampa, FL 33620-5350.

Contributors

Autar Kaw, Michael Keteltas

Format

Text/HTML

Last Revised

June 14, 2004

Identifier

http://numericalmethods.eng.usf.edu/ebooks/trapezoidal_07int_ebook.pdf

Language

English

Rights

http://numericalmethods.eng.usf.edu/rights.htm

 

Table of Contents

Background

        What is integration

Trapezoidal Rule

        Single-segment Trapezoidal Rule

        Multiple-segment Trapezoidal Rule

        Error in Multiple-segment Trapezoidal Rule

        PowerPoint presentation

Derivations

         Method 1: Derived from Calculus

         Method 2: Also derived from Calculus

         Method 3: Derived from Geometry

         Method 4: Derived from Method of Coefficients

         Method 5: Another approach on the Methods of Coefficients

Examples

          Example 1: Single segment Trapezoidal Rule

          Example 2: 2-segment Trapezoidal Rule

          Example 3: Multiple-segment Trapezoidal Rule

          Example 4: Multiple-segment Trapezoidal Rule

Simulations

         Method [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

           Convergence [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

 

Problem Sets

              Multiple choice question examination

              Problem Set: Discrete Functions

              Problem Set: Continuous Functions

Background

This is an example of how an instructor of a Numerical Methods course can develop an E-book on a single topic by using resources that are only available at the Holistic Numerical Methods Institute (HNMI) Website.

Although one of the primary advantages of a web-based resource is that one can use documents outside of its own domain, we are particularly using this example as a way to illustrate the holistic nature of the resources available at HNMI.   You are welcome to modify and edit this e-book to suit your purpose.

Using the textbook document written in MS Word 2000 as a foundation, it was made interactive within MS Word 2000 by putting bookmarks and hyperlinks to background information, PowerPoint presentations, Mathcad simulations, historical anecdotes, multiple choice tests, problem sets, etc.   Then the MS Word 2000 file was saved as a webpage and that is what you are about to read here.

Back to TOC

 

What is integration?

Integration is the process of measuring the area under a function plotted on a graph.  Why would we want to do so?  Among the most common examples are finding the velocity of a body from acceleration functions, and displacement of a body from velocity data.  Throughout the engineering fields, there are (what sometimes seems like) countless applications for integral calculus.  Sometimes, the evaluation of expressions involving these integrals can become daunting, if not indeterminate.  For this reason, a wide variety of numerical methods have been developed to find the integral. 

Here, we will discuss the trapezoidal rule of approximating integrals of the form

 


Figure 1: Integration of a function

 

 

 

 

 


 

Back to TOC

TRAPEZOIDAL RULE:

            Trapezoidal rule is based on the Newton-Cotes formula that if one approximates the integrand by an nth order polynomial, then the integral of the function is approximated by the integral of that nth order polynomial.  Integrating polynomials is simple and is based on the calculus formula.

                                                                                 (1)

So if we want to approximate the integral

                                                                                                          (2)

to find the value of the above integral, one assumes

                                                                                                          (3)

where

.                                                                 (4)

where  is an  order polynomial.  Trapezoidal rule assumes , that is, the area under the linear polynomial (straight line),

           

 

Back to TOC

DEREVATION OF THE TRAPEZOIDAL RULE:

 

Method 1: Derived from Calculus

Hence

           

                          

   .                                                                     (5)

But what is a0 and a1?  Now if one chooses,  and  as the two points to approximate  by a straight line from  to ,

 

                                                                                         (6)

                                                                                         (7)

 

Solving the above two equations for  and  ,

                                                                                                          (8)

Hence from Equation (5),

                                                                             (9)

 

Back to TOC

Method 2: Also derived from Calculus

 can also be approximated by using the Newton’s divided difference polynomial as

                                                                     (10)

Hence

           

                          

                          

                          

                          

                          

                          

                          

                          

                                                                           (11)

This gives the same result as Equation (10) because they are just different forms of writing the same polynomial.

 

Back to TOC

Method 3: Derived from Geometry

            The Trapezoidal rule can also be derived from geometry.  Look at Figure 2.  The area under the curve f1(x) is a trapezoid.  The integral

              

              

                                 (12)

                                                                                       Figure 2: Geometric Representation

Back to TOC

Method 4: Derived from Method of Coefficients

Trapezoidal rule can also be derived by the method of coefficients.  The formula

                                                                                    (13)

  

where

 

 

           

           

     

                                                                           Figure 3: Area by Coefficients

 

The interpretation is that  is evaluated at points  and , and each function evaluation is given a weight of .  Geometrically, Equation (12) is looked at as an area of a trapezoid, while Equation (13) is viewed as the sum of the area of two rectangles, as shown in Figure 3.  How can one derive trapezoidal rule by the method of coefficients? 

 

Assume

                                                                                             (14)

Let the right hand side be an exact expression for integrals of  and , that is, the formula will then also be exact for linear combinations of  and , that is, .

                                                                                                      (15)

                                                                                             (16)

Solving the above two equations gives

           

                                                                                                                        (17)

Hence

.                                                                    (18)

 

Back to TOC

Method 5: Another approach on the Method of Coefficients

Trapezoidal rule can also be derived by the method of coefficients by another approach

Assume

                                                                                             (19)

Let the right hand side be exact for integrals of the form

           

So

           

                                                                                               (20)

But we want

                                                                                     (21)

to give the same result as Equation (20) for .

           

                                                                                            (22)

Hence from Equations (20) and (22),

           

Since  and  are arbitrary for a general straight line

              

                                                                                                          (23)

Again, solving the above two equations (23) gives

           

                                                                                                                        (24)

Therefore

           

                                                                                                (25)

 

Back to TOC

Example 1

The vertical distance covered by a rocket from  to  seconds is given by

           

a)     Use single segment Trapezoidal rule to find the distance covered.

b)     Find the true error, Et for part (a).

c)     Find the absolute relative true error for part (a).

 

 

Solution

a)         , where

        

      *

           

           

                    

           

                      

           

              

b) The exact value of the above integral is

*  

*     

so the true error is

           

                

                

c) The absolute relative true error, , would then be

                    

                 

                 

 

Back to TOC

Multiple-segment Trapezoidal Rule:

            In Example 1, the true error using a single segment trapezoidal rule was large.  We can divide the interval [8, 30] into [8, 19] and [19, 30] intervals and apply Trapezoidal rule over each segment.

           

     

                   

           

           

Hence

           

                         

The true error,

           

                 

The true error now is reduced from 807 m to 205 m.  Extending this procedure to dividing  into  equal segments and apply the Trapezoidal rule over each segment, the sum of the results obtained for each segment is the approximate value of the integral.

            Divide  into  equal segments as shown in Figure 4.  Then the width of each segment is

           

 

                                (26)

 

 

 

 

Figure 4: Multiple (n=4) Segment Trapezoidal Rule

 

The integral I can be

broken into h integrals as

                                                                       

                                    (27)

 

Applying Trapezoidal rule Equation (27) on each segment gives

           

                             

      *………………

     

                             

                          

                             

                        *  ………………

                             

                             

                          

                          

                                                                   (28)

Back to TOC

Simulations

     Method [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

      Convergence [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]

Example 2

The vertical distance covered by a rocket from  to  seconds is given by

           

a)      Use two-segment Trapezoidal rule to find the distance covered.

b)      Find the true error, Et for part (a).

c)      Find the absolute relative true error for part (a).

Solution:

a) The solution using 2-segment Trapezoidal rule is

           

           

        

           

           

              

         *

           

  

  

  

 

b) The exact value of the above integral is

*  

*     

so the true error is

           

                

                

c) The absolute relative true error, , would then be

                    

                 

                 

 

 

 

 

 

Table 1:  Values obtained using multiple-segment Trapezoidal rule for            

 

n

Value

Et

1

11868

-807

7.296

---

2

11266

-205

1.853

5.343

3

11153

-91.4

0.8265

1.019

4

11113

-51.5

0.4655

0.3594

5

11094

-33.0

0.2981

0.1669

6

11084

-22.9

0.2070

0.09082

7

11078

-16.8

0.1521

0.05482

8

11074

-12.9

0.1165

0.03560

 

Back to TOC

Example 3:

Use Multiple-segment Trapezoidal Rule to find the area under the curve

           

from  to .

 

Solution

Using two segments, we get

                

           

           

          

                

                   

                   

                       

So what is the true value of this integral?

           

Making the absolute relative true error

           

                 

Why is the true value so far away from the approximate values?  Just take a look at Figure 5.  As you can see, the area under the “trapezoids” (yeah, they really look like triangles now) covers a small the area under the curve.  As we add more segments, the approximated value quickly approaches the true value.

 

                                                                       Figure 5: 2-Segment Approx. of an Exp. Function

 

Table 2: Values obtained using Multiple-segment Trapezoidal Rule for

n

Approximate Value

1

0.681

245.91

99.724%

2

50.535

196.05

79.505%

4

170.61

75.978

30.812%

8

227.04

19.546

7.927%

16

241.70

4.887

1.982%

32

245.37

1.222

0.495%

64

246.28

0.305

0.124%

 

 

 

Back to TOC

Example 4:

Use multiple-segment Trapezoidal Rule to find

           

Solution

We cannot use Trapezoidal Rule for this integral, as the value of the integrand at  is infinite.  However, it is known that a discontinuity in a curve will not change the area under it.  We can assume any value for the function at .  The algorithm to define the function so that we can use multiple-segment Trapezoidal Rule is given below.

           

            Function f(x)

            If x = 0  Then f = 0

            If x <> 0  Then f = x ^ (-0.5)

            End Function

 

Basically, we are just assigning the function a value of zero at .  Everywhere else, the function is continuous.  This means the true value of our integral will be just that—true.  Let’s see what happens using multiple-segment Trapezoidal Rule:

Using two segments, we get

                 

           

           

         

                

                   

                   

                   

                   

 

So what is the true value of this integral?

           

Thus making the absolute relative true error

           

                 

Table 3: Values obtained using Multiple-segment Trapezoidal Rule for

Number of Segments

Approximate Value

2

1.354

1.474

52.14%

4

1.792

1.036

36.64%

8

2.097

0.731

25.85%

16

2.312

0.516