Problem: Let be a positive valued (bounded) function on a closed (finite) interval of the real numbers. Compute the area of the region in the plane bounded by the graph of , the -axis and the straight lines .
EXAMPLE 1.1.
 f:=x->x*sin(x)^2;
 plot(f(x),x=1..3,y=0..2,scaling=CONSTRAINED);
For ``general'' functions this looks like a hard problem. However, for
some types of special functions (e.g. linear functions) the problem is
easy. Let us look at stepfunctions. A stepfunction on
is given by a subdivision of
, i.e. a finite sequence of numbers
and function values
such that for all such that
for all , whereas for all and .
Since stepfunctions play an important role we introduce the procedure
stepfunction to produce them. It has two arguments, a subdivision
and a list of function values . With the notations above
and
.
EXAMPLE 1.2.
 S:=[3,3.7,5,6.2,7.1,8]: V:=[2.5,-1,4.2,3,-2]:
 g:=stepfunction(S,V):
 plot(g,x=0..10,scaling=CONSTRAINED);
For positive stepfunctions the solution to the area problem
is immediate and given by the formula
Note that this formula makes sense for general stepfunctions: the
resulting number represents the area above the -axis minus the area
below the -axis. The procedure int_step yields the above sum for
given and .
EXAMPLE 1.3.
For the stepfunction in Example 1.2. the area
under the graph of is
 int_step(S,V);
Now back to the problem for general functions. The idea is to
approximate such a function by stepfunctions. E.g.,
a continuous function can be well approximated with constant on sufficiently small intervals. Let us look at the function of Example 1.1.
EXAMPLE 1.4.
Take a regular subdivision of , i.e. a subdivision into
subintervals of equal length.
 f:=x->x*sin(x)^2:
 n:=10:
 S:=[seq(1.+2*`i`/n,`i`=0..n)];
For the value of the stepfunction on
we choose .
Hence
 V:=[seq(f(S[`i`]),`i`=2..n+1)];
 g:=stepfunction(S,V):
 plot(\{f(x),g(x)\},x=1..3);
This plot shows the function and its approximating
stepfunction . Some daemon (in fact Maple's
procedure int) tells us that the area under the graph of
equals to whereas the area under the
graph of is given by
 int_step(S,V);
which can be rounded to . Neither very good nor totally bad as an
approximation. We can get a better approximation by increasing the
number of subintervals:
 n:=50: S:=[seq(1.+2*`i`/n,`i`=0..n)]:
 V:=[seq(f(S[`i`]),`i`=2..n+1)]:
 g:=stepfunction(S,V):
 plot(\{f(x),g(x)\},x=1..3,numpoints=500); g:='g':
 int_step(S,V);
rounded to , a much better approximation.
Exercise 1.1.
Consider the function
The region under the graph of between is a degree
circle sector. Hence the area equals to . Use the above method of approximation by regular
stepfunctions to find an approximation of . How many subintervals are needed to approximate with an error less then or equal to ?
The Maple package ``student'' contains the functions leftsum and
rightsum, which are in case of regular subdivision the same as
the function int_step. I.e., the function leftsum (rightsum) computes a numerical approximation to a definite integral using rectangles. The
height of each rectangle is determined by the value of the function at
the left (right) side of each subinterval. A graph of the
approximation can be obtained by the Maple procedure leftbox
(rightbox).
Exercise 1.2.
Approximate the function
on the intarval by regular stepfunctions using the procedure
with an error less than . How many subintervals were needed in
each case?
|