PROGRAM GAUNTEGRATE (INPUT,OUTPUT);
(****************************************************************************
LAWRENCE ADKINS,  MSA 326, SECT 1, COMPUTER PROJECT NO. 4
CONTE AND DEBOORE, PAGE 306(5.4-6), SPRING, 1979
 ****************************************************************************
SOLVE PROBLEMS 5.3-3(A,B,C) ON PAGE 298 USING THE GAUSSIAN FIVE POINT FORMULA
FORMULA AS AN APPROXIMATION TO THE REQUIRED INTEGRALS.

CHANGE /INTEGRAL FROM 0 TO 1 OF (F(X) DX)/  TO
/ (1/2) * INTEGRAL FROM -1 TO 1 OF (G(T) DT)/
WHICH IS APPROXIMATELY EQUAL TO 
/ (1/2) * SUMMATION FROM K=0 TO 4 OF (AWEIGHT[K] * G(XIPOINT[K])) /
IN ALL THREE CASES ONLY THE FUNCTION G CHANGES; THE WEIGHTS AND POINTS
USED REMAIN THE SAME.  THEY ARE COPIED FROM A TABLE ON PAGE 304 OF
CONTE AND DEBOORE.
 ****************************************************************************)
CONST N=4;  (*5-1:=4*)
TYPE TABLE = RECORD
  XIPOINT : ARRAY [0..N] OF REAL;
  AWEIGHT : ARRAY [0..N] OF REAL
  END;
VAR GAUSS: TABLE; I,C: REAL; J,K: 0..N;

PROCEDURE FILLINGAUSS;
  BEGIN
  GAUSS.XIPOINT[2] := 0;           GAUSS.AWEIGHT[2] := 0.56888889;
  GAUSS.XIPOINT[4] := 0.90617985;  GAUSS.AWEIGHT[4] := 0.23692689;
  GAUSS.XIPOINT[0] :=-0.90617985;  GAUSS.AWEIGHT[0] := 0.23692689;
  GAUSS.XIPOINT[3] := 0.53846931;  GAUSS.AWEIGHT[3] := 0.47862867;
  GAUSS.XIPOINT[1] :=-0.53846931;  GAUSS.AWEIGHT[1] := 0.47862867;
  END;
FUNCTION F1 (T:REAL): REAL;
  BEGIN F1 := ((T+1)/2)*EXP(-(T+1)/2) END;
FUNCTION F2 (T:REAL): REAL;
  BEGIN F2 := ((T+1)/2)*SIN( (T+1)/2) END;
FUNCTION F3 (T:REAL): REAL;
  VAR TEMP: REAL;
  BEGIN TEMP := 1 + SQR((T+1)/2); F3 := SQRT(TEMP*TEMP*TEMP) END;
PROCEDURE SOLVE (CONSTANT: REAL;  FUNCTION G(T: REAL): REAL);
  BEGIN
  I:= 0;
  FOR J:= 0 TO (N-1)
  DO I := I + (GAUSS.AWEIGHT[J] * G(GAUSS.XIPOINT[J]));
  I := CONSTANT * I
  END;

BEGIN
FILLINGAUSS; C:= 0.5; WRITELN ('R E S U L T S');
SOLVE (C,F1); WRITELN ('PROB 5.3-3-A) := ',I);
SOLVE (C,F2); WRITELN ('PROB 5.3-3-B) := ',I);
SOLVE (C,F3); WRITELN ('PROB 5.3-3-C) := ',I)
END.
