New Reply

Power series with subprograms Fortran 77 HELP

 
Share Thread Thread Tools
Apr9-12, 08:20 PM   #1
 

Power series with subprograms Fortran 77 HELP


1. The problem statement, all variables and given/known data
The power series
1 + x + (X^2)/2! + (x^3)/3! +....(to infinity)= (x^k)/k!
converges to e^x for all values of x. Write a function subprogram that uses this series to calculate values for e^x 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) = (e^x + e^-x)/2
and also the corresponding values of the library function COSH for x = -1 to 1 in increments of .1


3. The attempt at a solution
c Print the table heading
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


I keep getting a ton of errors. Am I setting up the structure of the DO X=-1, 1, .1 with the functions right?
 
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> 'Whodunnit' of Irish potato famine solved
>> The mammoth's lament: Study shows how cosmic impact sparked devastating climate change
>> Curiosity Mars rover drills second rock target
New Reply

Tags
cosine, fortran, power, programming, series
Thread Tools


Similar Threads for: Power series with subprograms Fortran 77 HELP
Thread Forum Replies
Truncated Sin Series in FORTRAN Programming & Comp Sci 4
Taylor Series using Geometric Series and Power Series Calculus & Beyond Homework 5
Exploiting Geometric Series with Power Series for Taylors Series Calculus & Beyond Homework 11
Demonstrate that the derivative of the power series of e^x, it's its own power series Calculus & Beyond Homework 11
Fortran power station 4.0 problem Programming & Comp Sci 0