Jump to content

Trigonometric functions: Difference between revisions

added Fortran
No edit summary
(added Fortran)
Line 147:
cr fdup facos f.
cr fatan f. \ also available: fatan2 ( r1 r2 -- atan[r1/r2] )
 
=={{header|Fortran}}==
Trigonometic functions expect arguments in radians so degrees require conversion
PROGRAM Trig
REAL pi, dtor, rtod, radians, degrees
pi = 4.0 * ATAN(1.0)
dtor = pi / 180.0
rtod = 180.0 / pi
radians = pi / 4.0
degrees = 45.0
WRITE(*,*) SIN(radians), SIN(degrees*dtor)
WRITE(*,*) COS(radians), COS(degrees*dtor)
WRITE(*,*) TAN(radians), TAN(degrees*dtor)
WRITE(*,*) ASIN(SIN(radians)), ASIN(SIN(degrees*dtor))*rtod
WRITE(*,*) ACOS(COS(radians)), ACOS(COS(degrees*dtor))*rtod
WRITE(*,*) ATAN(TAN(radians)), ATAN(TAN(degrees*dtor))*rtod
END PROGRAM Trig
Output:
0.707107 0.707107
0.707107 0.707107
1.00000 1.00000
0.785398 45.0000
0.785398 45.0000
0.785398 45.0000
The following trigonometric functions are also available
ATAN2(y,x) ! Arctangent(y/x), ''-pi < result <= +pi''
SINH(x) ! Hyperbolic sine
COSH(x) ! Hyperbolic cosine
TANH(x) ! Hyperbolic tangent
 
=={{header|Haskell}}==
179

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.