Areas between Curves

Copyright 2001
Department of Mathematics
University of Georgia
Athens, Georgia

John Gosselin

Introduction

Areas between the graphs of two functions.

In this lab project you will use Maple to compute areas between two curves. We assume our functions have continuous derivatives over any interval of integration. In general the area between the graphs of two functions f(x) and g(x)  is given by int(f(x)-g(x),x = a .. b)  where the graph of f(x) lies above the graph of g(x) over the interval from a  to b . In general given two functions f(x) and g(x), their graphs partition or divide the plane up into disjoint regions. When one asks for the area between the graphs of two functions it is assumed that there are a finite number of regions having finite areas and the area between the graphs of these functions is the sum of the areas of the regions having finite areas. When asked to determine the area between the graphs of f(x) and g(x) one often has to solve for points of intersection. Sometimes such points can be solved for algebraically but more often than not one must solve for such points numerically with the fsolve  command.

Example

To determine the area between the graphs of f(x) = 4-x^2  and g(x) = x^2-2*x-3  we begin by plotting the graphs of these two functions.

>    f:=x->4-x^2;

>    g:=x->x^2-2*x-3;

>    plot({f(x),g(x)},x=-4..4);

Since both of our functions are quadratic functions, we know that their graphs are both parabolas and only intersect as shown in the above graph. These graphs divide the plane up into five regions only one of which has finite area. In order to calculate this area we need to determine the points of intersection. One point of intersection lies between x = -2 and x = -1 and the other point of intersection lies between x = 2 and x = 3.

>    a:=fsolve(f(x)=g(x),x=-2..-1);

>    b:=fsolve(f(x)=g(x),x=2..3);

We now can determine the area between the graphs of f(x) and g(x).

>    int(f(x)-g(x),x=a..b);

In general if there is more than one region with finite area, one must break up the intergral into a sum of integrals each over an appropriate interval where the graph of either f(x) or g(x) is always  the upper function throughout the interval. For example suppose we wish to determine the area between the graphs of f(x) = x^3-2*x+1  and g(x) = x+2 .

>    restart:

>    f:=x->x^3-2*x+1;

>    g:=x->x+2;

>    plot({f(x),g(x)},x=-3..3,y=-10..10);

In this case there are two regions with finite area between the graphs of f(x) and g(x). In this case we must solve for the x-coordinates of three points of intersection.

>    a:=fsolve(f(x)=g(x),x=-2..-1);

>    b:=fsolve(f(x)=g(x),x=-1..-0);

>    c:=fsolve(f(x)=g(x),x=1..2);

We now calculate the area between the graphs of f(x) and g(x).

>    int(f(x)-g(x),x=a..b)+int(g(x)-f(x),x=b..c);

Note that if we integrate f(x) - g(x) from a to c, we get a different answer since the area between b and c is counted as negative area.

>    int(f(x)-g(x),x=a..c);

As a practice exercise calculate the area between the graphs of f(x) = -x/2+1  and g(x) = 3*cos(x) . Begin by plotting these functions over the interval from -10 to 10.

>    restart:

>    f:=x->-x/2+1;

>    g:=x->3*cos(x);

>    plot({f(x),g(x)},x=-10..10);

>   

>   

>   

Area as Integrals with respect to y

Sometimes it is more convenient to calculate the area between two curves in the plane by integrating along the y -axis. This is particularly convenient when the curves are easily described as functions of the variable y . When integrating with respect to y , one must still be concerned about curves intersecting and certain areas being counted as negative area. The notions of "upper function" and "lower function" are replaced by "function on the right" and "function on the left" respectively. More precisely, when integrating along the y -axis, area is counted as positive  when the integrand is the difference between a function on the right and a function on the left or int(right*function-left*function,y = a .. b) . Note that when dealing with functions of y  we use the implicitplot  tool of Maple to draw our graphs. When using the implicit plot command sometimes it is necessary to specify that more points be used in the grid. This is done with the  grid  option within the implicitplot  command. In the following plot we have specified that 50 points be used in each direction. This forces Maple to use 2500 points within the rectangle [-5,5] by [-5,5]. The maximum valued within the grid option is 100 which results in 10,000 points. Specifying more grid points slows down the plotting but generally results in smoother, less jagged curves.  

Suppose we wish to determine the area between the curves x = y^2-2*y-1  and 2*x-y-2 = 0 .

>    restart:with(plots):

>    implicitplot({x=y^2-2*y-1,2*x-y-2=0},x=-5..5,y=-5..5,grid=[50,50],scaling=constrained);

In this case we are calculating the area between a horizontal parabola and a straight line. If we try to calculate the area as an integral with respect to x  we must write the area as the sum of two integrals and we would need to express the top and bottom halves of the parabola as functions of x . However we can calculate our area as a single integral with respect to y . We begin by finding the points of intersection with the fsolve  command

>    fsolve({x=y^2-2*y-1,2*x-y-2=0},{x,y},y=-2..0);

>    fsolve({x=y^2-2*y-1,2*x-y-2=0},{x,y},y=2..4);

We define the upper and lower limits of integration as variables c  and d .

>    c:=-.6374586088;d:=3.137458609;

We now calculate our area by integrating the difference between  the function on the right (the line) and the function on the left (the parabola).

>    solve(2*x-y-2=0,x);

>    int(1/2*y+1-(y^2-2*y-1),y=c..d);

Exercise

Calculate the area of the same region as the sum of two integrals with respect to the variable x . You will need to express the upper and lower halves of the parabola in terms of x . This can be done easily with the solve  command.

>    solve(x=y^2-2*y-1,y);

>   

>   

>   

Areas between More General Curves

Not every curve in the plane is the graph of a function. For example the unit circle centered at the origin is neither the graph of a function of x nor the graph of a function of y. It is the solution set  of the equation x^2+y^2 = 1 . In many situations we can calculate the area between two curves that are the solution sets of given equations. In order to see the graphs of such curves, the implicitplot  of Maple is very convenient.

As an example suppose we wanted to find the area inside the curve x^2+y^2 = 4  and above the y = -1.2*x+1 .

>    restart:with(plots):

>    implicitplot({x^2+y^2=4,y=-1.2*x+1},x=-5..5,y=-5..5,scaling=constrained);

Note that as x  varies from left to right the upper function is the upper half of the circle. To the left of the point where the circle and line intersect in the fourth quadrant, the lower function is the straight line. To the right of this point of intersection the lower function is the lower half of the circle. To calculate the area between the line and the circle we must write the area as the sum of two integrals each one having a different lower function. We first use the fsolve  command to determine where the circle and line intersect.

>    fsolve({x^2+y^2-4=0,y=-1.2*x+1},{x,y},x=-2..0);

>    fsolve({x^2+y^2-4=0,y=-1.2*x+1},{x,y},x=0..2);

Note that the upper half of the circle is given by y = sqrt(4-x^2)  and the lower half of the circle is given by y = -sqrt(4-x^2) . The x -coordinate of the left point of intersection is -.7212007038  and the x -coordinate of the right point of intersection is 1.704807261 .

>    a:=-.7212007038;b:=1.704807261;

>    int(sqrt(4-x^2)-(-1.2*x+1),x=a..b)+int(sqrt(4-x^2)-(-sqrt(4-x^2)),x=b..2);

Exercise

The same area between the circle and the straight line can be calculated as a sum of integrals with respect to the variable y . Calculate the area as a sum of two integrals with respect to y .

>   

Project

1. Determine the area between the graphs of f(x) = sin(x)  and g(x) = cos(x^2)  over the interval from [ 0, Pi ]

>    restart:

>    f:=x->sin(x);g:=cos(x^2);

>    plot({f(x),g(x)},x=0..Pi);

>   

>   

2.Let m  denote the number of letters in your first name. Determine the area between the curves x = y^2+m*y-2  and x = y^3/2-2*y+1 . There should be two regions with finite area. Adjust your viewing window so that both of these regions are in view.

>    restart:with(plots):

>    m:=;

>   

>   

>   

>   

3. Let n  denote the number of letters in your last name. Determine the area inside the curve x^2/4+3*y^2/(n^2) = 1  and  above the line y = -2*x+1 .

>    restart:with(plots):

>    n:=;

>   

>   

>   

>   

The Most Common Maple Commands

Academic Honesty Statement:

Place the following statement (by copying and pasting) at the end of your report and sign it in ink.  Your instructor will not grade your report unless this signed statement appears at the end of your report.

I understand that I may work with others if I give them credit in this statement.  I also understand that I am required to write my report--that to copy all or part of someone else's report or to allow someone else to copy all or part of my report constitutes plagiarism, which is a serious violation of academic honesty.

I worked with (replace this parenthetical remark with first and last names of those with whom you worked)  on this project.  I wrote my own report.  I did not copy any of this report from anyone else and I did not allow anyone else to copy any of this report.

Signed: