1. The power series 2! 3! k! converges to e for all values of z. Write a functio
ID: 3588587 • Letter: 1
Question
1. The power series 2! 3! k! converges to e for all values of z. Write a function subprogram that uses this series to calculate values for e to five-decimal-place accuracy (i.e, using terms up to the first one that is less than 10-5 in absolute value) and that uses a function subprogram to calculate factorials. Use these subprograms in a main program to calculate and print a table of values for the function cosh(x) = 2 and also the corresponding values of the library function COSH for1 to 1 in increments of 0.1Explanation / Answer
100 FORMAT(3X, A7, 5X, A16, 2X) PRINT 100, 'COSH(X)', 'LIBRARY COSH(X)' PRINT *, '==============================='
c ===========================================================
REAL FUNCTION COSH (G)
REAL G
DO 80 G = -1., 1., .1
COSH = COSH (G)
80 CONTINUE
END
c =============================================================
REAL FUNCTION HCOSN (POWER)
REAL POWER
HCOSN = (POWER + (1/POWER))/2
END
c ==============================================================
REAL FUNCTION POWER (X,I)
INTEGER FACTOR, I
REAL X
DO 20 X= -1., 1., .1
POWER = (X**I)/FACTOR
20 CONTINUE
END
c ===============================================
INTEGER FUNCTION FACTOR(N)
INTEGER N, I
FACTOR = 1
DO 10 I = 2, N
FACTOR = FACTOR * I
10 CONTINUE
END
c ==============================================================
130 FORMAT (3X, F5.5, 7X, F5.5)
PRINT 130, HCOSN, COSH
PAUSE
END
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.