      PROGRAM AREA
************************************************************************
* Program to approximate the integral of a function over the interval  *
* [A,B] using the rectangle method.  This approximation is calculated  *
* by the function subprogram DEFINT; the integrand, the interval of    *
* integration, and the # of subintervals are passed as arguments to    *
* DEFINT.  Identifiers used are:                                       *
*     A, B   : the endpoints of the interval of integration            *
*     SIN    : the integrand (library function)                        *
*     SUBS   : the number of subintervals used                         *
*                                                                      *
* Input:  A, B, and SUBS.                                              *
* Output: Approximation to integral of F on [A, B].                    *
************************************************************************

      REAL A, B, DEFINT
      INTEGER SUBS
      INTRINSIC SIN

      PRINT *, 'ENTER THE INTERVAL ENDPOINTS AND THE # OF SUBINTERVALS'
      READ *, A, B, SUBS
      PRINT *, 'RECTANGLE APPROXIMATION WITH',  SUBS, 
     +         ' SUBINTERVALS IS', DEFINT(SIN, A, B, SUBS)
      END


**DEFINT****************************************************************
* Function to calculate the rectangle approximation of the integral    *
* of the function F over the interval [A,B] using N subintervals.      *
* Altitudes of rectangles are chosen at tne midpoints of the           *
* subintervals.  Local variables used are:                             *
*     I      : counter                                                 *
*     DELX   : length of the subintervals                              *
*     X      : midpoint of one of the subintervals                     *
* Accepts: Function F, endpoints A and B, and number N of subintervals.*
* Returns: Approximate value of integral of F over [A, B].             * 
************************************************************************

      FUNCTION DEFINT(F, A, B, N)

      INTEGER N, I
      REAL DELX, X, DEFINT

      DELX = (B - A) / N
      DEFINT = 0
      X = A + DELX / 2
      DO 10 I = 1, N
          DEFINT = DEFINT + F(X)
          X = X + DELX
10    CONTINUE
      DEFINT = DEFINT * DELX
      END

