By "area under a curve" we mean the area bounded by a curve and the x-axis (the line y = 0), between specified limits. The area can be positive if the curve lies above the x-axis or negative if it is below.
Calculation of the area under a curve is sometimes referred to as quadrature, since it involves subdividing the area under the curve into a number of "panels" whose areas can be calculated. The sum of the areas of the panels will be an approximation to the area under the curve. The three most common approaches are the rectangle method, in which the panels are rectangles, the trapezoid method, in which the panels are trapezoids and Simpson's method, which approximates the curvature of the function. These methods require that we have a table of values of the function; the three methods are illustrated in Figure 7-1. Only Simpson's method requires panels of equal width.
The simplest approach is to approximate the area of the panel by a rectangle whose height is equal to the value of one of the two data points, illustrated in Figure 7-1. If we have a table of n data points, we will have n-1 panels.
As the x increment (the interval between the data points) decreases, this rather crude approach becomes a better approximation to the area. The area under the curve bounded by the limits Xjnitial and xfmai is the sum of the n individual rectangles, as given by equation 7-1.
A better approximation is to use the average of the two y values as the height of the rectangle. This is equivalent to approximating the area by a trapezoid rather than a rectangle. The area under the curve is given by equation 7-2.
Axis Title
Figure 7-1. Graphical illustration of methods of calculating the area under a curve.
Axis Title
Figure 7-1. Graphical illustration of methods of calculating the area under a curve.
Simpson's 1/3 rule approximates the curvature of the function by means of a quadratic interpolating polynomial. The 1/3 rule, calculated by means of equation 7-3, requires two intervals of equal width h; thus each element of area is evaluated by using three data points.
The 1/3 rule requires an even number of panels; thus the number of data points n must be an odd number. If n is even, the area of the first or last panel can be calculated using the trapezoid formula. The end panel to be so calculated should be the one in which the function is more linear.
Simpson's 3/8 rule (equation 7-4) approximates the area by a cubic interpolating polynomial, evaluates the area of three panels of equal width, and requires four data points for each element of area.
The 3/8 rule is often used when evaluating the area under a curve described by an odd number of panels: the first or last three panels are evaluated using the 3/8 rule, and the remainder by the 1/3 rule.
Calculating the Area under a Curve Defined by a Table of Data Points
In the fields of toxicology and pharmacology, the area under the curve of a plot of plasma concentration of a drug versus elapsed time after administration of the drug has a number of important uses. The area can used to calculate the total body clearance and the apparent volume of distribution.
In a study, a drug was administered intravenously to a patient. Blood samples were taken at intervals of time, plasma was separated from each blood sample, and the plasma samples were analyzed for drug concentration. The data are shown in Figure 7-2. The dashed line indicate extrapolation of the data.
Time after administration, hr
Figure 7-2. Plot of drug concentration versus time, (folder 'Chapter 07 Examples', workbook 'Area under Curve', worksheet 'Curve 1 by worksheet')
Time after administration, hr
Figure 7-2. Plot of drug concentration versus time, (folder 'Chapter 07 Examples', workbook 'Area under Curve', worksheet 'Curve 1 by worksheet')
?___A_____ |
.. .B ! C I | ||
1 |
Time, hr |
Cone, M^/rnL |
area |
2 |
0 |
95 | |
3 |
0.5 |
85 |
45 |
4 |
1 |
74 |
39.75 |
5 |
2 |
55 |
64.5 |
6 |
3 |
41 |
48 |
7 |
4 |
" 3Q |
35.5 |
6 |
5 |
22 |
26 |
9 |
6 |
17 |
19.5 |
10 |
7 |
12 |
14.5 |
11 |
8 |
9 1 |
10.55 |
12 |
9 |
6.7 |
7.9 |
13 |
11 |
4.0 |
10.7 |
14 |
20 |
0 |
18: |
15 |
Sum = |
340 |
Figure 7-3. Calculating the area under a curve, (folder 'Chapter 07 Examples', workbook 'Area under Curve', worksheet 'Curve 1 by worksheet')
Figure 7-3. Calculating the area under a curve, (folder 'Chapter 07 Examples', workbook 'Area under Curve', worksheet 'Curve 1 by worksheet')
The formula in cell C3, used to calculate the area increment by the trapezoidal approximation, is
The area increments were summed to obtain the area under the curve.
Calculating the Area under a Curve Defined by a Table of Data Points by Means of a VBA Function Procedure
A simple VBA custom function to find the area under a curve defined by a table of x, y data points, using the trapezoidal approximation, is shown in Figure 7-4. The syntax of the function is CurvArea(x_values, y_values).
Function CurvArea(x_values, y_values) 'Simple trapezoidal area integration
area = area + (x_values(J) - x_values(J -1)) * (y_values(J) + y_values(J -1)) / 2 Next J
CurvArea = area End Function
Figure 7-4. Simple VBA function CurvArea to calculate the area under a curve, (folder 'Chapter 07 Examples', workbook 'Area under Curve', module 'CurvArea')
Calculating the Area under a Curve Defined by a Formula
Instead of determining the area under a curve defined by a table of data points, you may need to determine the area under a curve defined by a formula. For example, you may need to determine the area under the curve defined by equation 7-6
which is shown in Figure 7-5. It is clear from the figure that summing areas of panels from x = 0 to x = 15 will provide an accurate determination of the area. In the calculation of the area, you are not limited by a table of values, as in the previous section, but instead you can create your own table by calculating values of the function for a range of suitable jc values. Nor are you limited to using Panels of equal width. You can increase the accuracy obtained from the simple trapezoidal function by choosing panels of smaller width in regions where the curvature is greater. A chart of the function will show where the x increments should be made smaller; this should be evident from Figure 7-5.
Part of the data table is shown in Figure 7-6, along with the area under the curve calculated by the trapezoidal approximation. The result returned by the custom function
is 6.514. The exact value for the area under the curve is ti4/15 = 6.494; the error in the value returned by the custom function is 0.3%.
A |
B 1 |
c t | |
1 |
Integration of Area Ululer a Curve | ||
2 |
y=x3/(eI-1) | ||
3 |
X |
y |
area |
4 |
0 |
o | |
5 |
0,05 |
0.002438 |
0.000061 |
6 |
0,1 |
0 009508 |
0.000299 |
7 |
0.2 |
0.036133 |
0.002282 |
8 |
0.4 |
0.13012B |
0.016626 |
9 |
0.6 |
0.262736 |
0.039286 |
10 |
0.8 |
0.417775 |
0.068051 |
11 |
1 |
0.581977 |
0.099975 |
12 |
1,2 |
0.744790 |
0,132677 |
3E |
14 |
0 002282 |
0.003624 |
39 |
15 |
0.001032 |
0.001657 |
40 |
Sum = |
6.514127; |
Figure 7-6. Portion of data table for calculation of area under a curve. Note that rows 13-37 have been hidden, (folder 'Chapter 07 Examples', workbook 'Area under Curve', worksheet 'Curve2 by worksheet')
Figure 7-6. Portion of data table for calculation of area under a curve. Note that rows 13-37 have been hidden, (folder 'Chapter 07 Examples', workbook 'Area under Curve', worksheet 'Curve2 by worksheet')
The area between two curves can be determined by using any of the calculation methods described previously. The area is determined by the absolute value of the difference between the two curves, as in equation 7-7.
There are several possibilities for the "area between two curves": the area can either be bounded by the curves f(x) and g(x) between specified limits (for example, the vertical lines x = a\ and x = b\ in Figure 7-7) or by the two curves f(x) and g(x) between two points where they cross (the points x = a2 and x = b2 in Figure 7-7).
For the first case (area bounded by two curves between specified limits) the calculation is straightforward. In the second case, it is necessary to find the two values of x where the curves intersect. This can be done "manually," by inspecting the table of values for f(x) and g(x), or by methods described later in this book (see "Finding Values Other Than Zeroes of a Function" in Chapter 8).
Was this article helpful?