next up previous
Next: Exercises Up: Background Previous: Partitions and rectangular approximations

Computing areas as definite integrals with Maple

In the example in the previous section, we saw that increasing the number of subintervals gave a better approximation to the area. In such a case, it seems reasonable that taking a limit as the number of subintervals goes to infinity should give the exact answer. This is exactly the idea in defining the definite integral. Of course, the actual definition of the definite integral involves more general sums than the ones we have been talking about, but the idea is the same.

When this limit as the number of subintervals goes to infinity exists, we have special notation for this limit and write it as


We will learn later on that if the function f(x) is continuous on the interval [a,b], then this limit always exists and we can write


where A is the area under the curve y=f(x) between x=a and x=b.

The Fundamental Theorem of Calculus (FTOC) provides a connection between the definite integral and the indefinite integral we studied earlier. That is, the FTOC provides a way to evaluate definite integrals if an anti-derivative can be found for f(x). We'll spend a lot of time later in the course developing ways to do this, but for now we'll let Maple do the work and won't worry too much about how it is done.

The basic maple command for performing definite and indefinite integrals is the int command. The syntax is very similar to that of the leftsum and rightsum commands, except you don't need to specify the number of subintervals. This should make sense, if you recall that the definite integral is defined as a limit of a rectangular sum as the number of subintervals goes to infinity. In the section on rectangular approximations, we used two examples. The first was the function tex2html_wrap_inline301 on the interval [0,4] and the second was the function y=x on the interval [0,2]. We would express the areas under these two curves with our integral notation as




Using Maple, we would compute these two definite integrals as shown below.

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


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


Notice that Maple gives an exact answer, as a fraction. If you want a decimal approximation to an integral, you just put an evalf command around the int command, as shown below.

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


In the exercises, we'll ask you to compare rectangular approximations to integrals. In doing so, you'll need to apply several commands to the same function. To save typing and prevent errors, you can define the function as a function or an expression in Maple first and then use it in subsequent int, leftsum, etc. commands. For example, suppose you were given the function tex2html_wrap_inline309 on the interval tex2html_wrap_inline311 . Then you can define this function in Maple with the command

  > f := x -> x*sin(x);


and then use this definition to save typing as shown below.

  > int(f(x),x=0..Pi);


  > evalf(leftsum(f(x),x=0..Pi,4));


You can also simply give the expression corresponding to f(x) a label in Maple, and then use that label in subsequent commands as shown below. However, notice the difference between the two methods. You are urged you to choose one or the other, so you don't mix the syntax up.

  > p := x*sin(x);


  > int(p,x=0..Pi);


next up previous
Next: Exercises Up: Background Previous: Partitions and rectangular approximations

Sean O Anderson
Fri Jan 17 13:12:57 EST 1997