PROGRAM series15 ! ! Author: Br. David Carlson ! ! Date: December 31, 1999 ! ! Revised: May 2, 2004; April 18, 2016 ! ! This program uses power series to find an approximate value for the ! integral of ln(x + 1) from 1/4 to 3/4. Compare with the output of integ3.f90. ! This is a quick solution using a sequence of assignment statements, which can ! be faster to write than finding the pattern needed to do the same calculations ! in a loop. IMPLICIT NONE REAL::x, xsquared, top, sum1, sum2 WRITE (*, 20) 20 FORMAT (1X, 'Program to integrate ln(x + 1) from 1/4 to 3/4 using series') x = 0.75 xsquared = x * x sum1 = 0.0 top = xsquared sum1 = sum1 + top / 2.0 top = top * x sum1 = sum1 - top / 6.0 top = top * x sum1 = sum1 + top / 12.0 top = top * x sum1 = sum1 - top / 20.0 top = top * x sum1 = sum1 + top / 30.0 top = top * x sum1 = sum1 - top / 42.0 top = top * x sum1 = sum1 + top / 56.0 top = top * x sum1 = sum1 - top / 72.0 top = top * x sum1 = sum1 + top / 90.0 top = top * x sum1 = sum1 - top / 110.0 x = 0.25 xsquared = x * x sum2 = 0.0 top = xsquared sum2 = sum2 + top / 2.0 top = top * x sum2 = sum2 - top / 6.0 top = top * x sum2 = sum2 + top / 12.0 top = top * x sum2 = sum2 - top / 20.0 top = top * x sum2 = sum2 + top / 30.0 top = top * x sum2 = sum2 - top / 42.0 top = top * x sum2 = sum2 + top / 56.0 top = top * x sum2 = sum2 - top / 72.0 top = top * x sum2 = sum2 + top / 90.0 top = top * x sum2 = sum2 - top / 110.0 WRITE (*, 200) sum1 - sum2 200 FORMAT (1X, 'The approximate value is ', E16.7) END PROGRAM