PROGRAM integ3 ! ! Author: Br. David Carlson ! ! Date: January 1, 2000 ! ! Revised: April 22, 2004; May 2, 2004; April 18, 2016 ! ! This program finds the approximate value of the integral of ln(x + 1) from 1/4 to 3/4. ! The q1da.f library routine is used. IMPLICIT NONE REAL::area, A, B, error, EPS INTEGER::KF, IFLAG ! Function used: REAL::F WRITE (*, *) 'Program to integrate ln(x + 1) from 1/4 to 3/4.' A = 0.25 B = 0.75 EPS = 0.00001 CALL Q1DA(A, B, EPS, area, error, KF, IFLAG) ! A ! B (INPUT) THE ENDPOINTS OF THE INTEGRATION INTERVAL ! EPS (INPUT) THE ACCURACY TO WHICH YOU WANT THE INTEGRAL ! COMPUTED. IF YOU WANT 2 DIGITS OF ACCURACY SET ! EPS=.01, FOR 3 DIGITS SET EPS=.001, ETC. ! EPS MUST BE POSITIVE. ! area (OUTPUT) Q1DA'S BEST ESTIMATE OF YOUR INTEGRAL ! error (OUTPUT) AN ESTIMATE OF ABS(INTEGRAL-area) ! KF (OUTPUT) THE COST OF THE INTEGRATION, MEASURED IN ! NUMBER OF EVALUATIONS OF YOUR INTEGRAND F. ! KF WILL ALWAYS BE AT LEAST 30. ! IFLAG (OUTPUT) TERMINATION FLAG...POSSIBLE VALUES ARE ! 0 NORMAL COMPLETION, error SATISFIES ! error < EPS AND error < EPS * ABS(area) ! 1 NORMAL COMPLETION, error SATISFIES ! error < EPS, BUT error > EPS * ABS(area) ! 2 NORMAL COMPLETION, error SATISFIES ! error < EPS * ABS(area), BUT error > EPS ! 3 NORMAL COMPLETION BUT EPS WAS TOO SMALL TO ! SATISFY ABSOLUTE OR RELATIVE ERROR REQUEST. ! ! 4 ABORTED CALCULATION BECAUSE OF SERIOUS ROUNDING ! ERROR. PROBABLY error AND area ARE CONSISTENT. ! 5 ABORTED CALCULATION BECAUSE OF INSUFFICIENT STORAGE. ! area AND error ARE CONSISTENT. ! 6 ABORTED CALCULATION BECAUSE OF SERIOUS DIFFICULTIES ! MEETING YOUR ERROR REQUEST. ! 7 ABORTED CALCULATION BECAUSE EPS WAS SET <= 0.0 ! ! NOTE...IF IFLAG=3, 4, 5 OR 6 CONSIDER USING Q1DAX INSTEAD. WRITE (*, 100) area 100 FORMAT (1X, 'The q1da library routine gives an integral value of: ', E17.7) WRITE (*, 200) error 200 FORMAT (1X, 'The error is estimated as: ', E17.7) WRITE (*, 300) KF 300 FORMAT (1X, 'The cost is estimated as: ', I7) WRITE (*, 400) IFLAG 400 FORMAT (1X, 'The IFLAG value is: ', I2) END PROGRAM ! Given: x a real value ! Task: Compute f(x) and return it. ! Return: Computed value in function name. REAL FUNCTION F(x) IMPLICIT NONE REAL, INTENT(IN)::x F = LOG(x + 1) END FUNCTION