next up previous
Next: Introduction to Volumes Up: Labs and Projects for Previous: Area Approximations

Analytical and Numerical Integration


The purpose of this lab is to give you practice performing analytical and numerical integration with Maple.


Integration in Maple

The Maple int command will handle most integrals that can be done analytically. Both definite and indefinite integrals can be done, as shown by the following examples.

  > int(x^2,x);

  > int(x^2,x=0..2);

  > int(sin(4*x),x);

  > int(x*(3*x^2+2)^(5/3),x);

Notice that Maple doesn't include a constant of integration for indefinite integrals.

Unfortunately, there are lots of integrals that can't be done analytically. (The ones that can be done tend to appear in calculus texts. The ones that can't be done often appear in real life.) When Maple can't do an integral, it simply returns it unevaluated. The example below show how to use the evalf command to get Maple to evaluate the integral numerically.

  > int(cos(x^3),x=0..1);

  > evalf(int(cos(x^3),x=0..1));

Maple uses a sophisticated numerical integration routine with automatic error control to evaluate definite integrals that it can't do analytically. In the next section of this lab, we introduce two simple numerical integration techniques that are widely used by engineers and scientists. These two methods are almost as simple as the rectangular rules from the last lab, but they are accurate enough to be useful.

Trapezoidal rule and Simpson's rule

The rectangular rules we used in the last lab are very simple to understand and use, but they are not very efficient. By this, we mean that a large number of subintervals is often required to get accurate results. Two widely used rules for approximating areas are the trapezoidal rule and Simpson's rule. The Maple student package has commands trapezoid and simpson that implement these methods. The command syntax is very similar to the rectangular approximations. See the examples below. Note that an even number of subintervals is required for the simpson command.

  > with(student):

  > trapezoid(x^2,x=0..4);

  > evalf(trapezoid(x^2,x=0..4));

  > evalf(trapezoid(x^2,x=0..4,10));

  > simpson(x^2,x=0..4);

  > evalf(simpson(x^2,x=0..4));

  > evalf(simpson(x^2,x=0..4,10));

The trapezoidal rule uses trapezoids to approximate the area over the subinterval as shown below with only two subintervals in Figure gif for .

Figure:  Geometry of the trapezoidal rule.

Since the area of a trapezoid is the width times the average of the two heights, the area of the trapezoid above the subinterval is

Adding up all the areas gives the usual formula

for a uniform partition with N subintervals. You can think of the trapezoidal rule as the result of approximating the function by straight line segments.

The derivation of Simpson's rule is more complicated and will not be discussed here. It is described in detail in the text. The basic idea is to fit the function with segments of parabolas. Three points are required to define a parabola, so two adjacent subintervals are used for each parabola segment. (This is why an even number of subintervals is required for Simpson's method.)


  1. Use Maple to compute the following definite and indefinite integrals.
    1. , where n is a positive constant.

  2. Use Simpson's rule and the trapezoidal rule to approximate the following areas to four decimal places. Your report should include the approximate values of the areas and the number of subintervals required for each method. Compare your results to those you obtained from the last lab. You should also use the int and evalf commands to generate ``exact'' answers.

    1. from x=0 to x=10..

    2. from x=0 to ..

next up previous
Next: Introduction to Volumes Up: Labs and Projects for Previous: Area Approximations

William W. Farr
Mon Jun 26 15:29:53 EDT 1995