COT
This function evaluates the cotangent.
Function Value Return
COT — Function value. (Output)
Required Arguments
X — Angle in radians for which the cotangent is desired. (Input)
FORTRAN 90 Interface
Generic: COT (X)
Specific: The specific interface names are COT, DCOT, CCOT, and ZCOT.
FORTRAN 77 Interface
Single: COT (X)
Double: The double precision function name is DCOT.
Complex: The complex name is CCOT.
Double Complex:  The double complex name is ZCOT.
Description
For real x, the magnitude of x must not be so large that most of the computer word contains the integer part of x. Likewise, x must not be too near an integer multiple of π, although x close to the origin causes no accuracy loss. Finally, x must not be so close to the origin that COT(X 1/x overflows.
For complex arguments, let z = x + iy. If sin z2 is very small, that is, if x is very close to a multiple of π and if y is small, then cot z is nearly singular and a fatal error condition is reported. If sin z2 is somewhat larger but still small, then the result will be less accurate than half precision. When 2x is so large that sin 2x cannot be evaluated accurately to even zero precision, the following situation results. If y < 3/2, then CCOT cannot be evaluated accurately to be better than one significant figure. If 3/2 ≤∣y < 1/2 ln ɛ/2, where ɛ = AMACH(4) is the machine precision, then CCOT can be evaluated by ignoring the real part of the argument; however, the answer will be less accurate than half precision. Finally, z must not be so small that cot z  1/z overflows.
Comments
1. Informational error for Real arguments
Type
Code
Description
3
2
Result of COT(X) is accurate to less than one‑half precision because ABS(X) is too large, or X is nearly a multiple of π.
2. Informational error for Complex arguments
Type
Code
Description
3
2
Result of CCOT(Z) is accurate to less than one‑half precision because the real part of Z is too near a multiple of π when the imaginary part of Z is zero, or because the absolute value of the real part is very large and the absolute value of the imaginary part is small.
3. Referencing COT(X) is not the same as computing 1.0/TAN(X) because the error conditions are quite different. For example, when X is near π/2, TAN(X) cannot be evaluated accurately and an error message must be issued. However, COT(X) can be evaluated accurately in the sense of absolute error.
Examples
Example 1
In this example, cot(0.3) is computed and printed.
 
USE COT_INT
USE UMACH_INT
 
IMPLICIT NONE
! Declare variables
INTEGER NOUT
REAL VALUE, X
! Compute
X = 0.3
VALUE = COT(X)
! Print the results
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) X, VALUE
99999 FORMAT (' COT(', F6.3, ') = ', F6.3)
END
Output
 
COT( 0.300) = 3.233
Example 2
In this example, cot(1 + i) is computed and printed.
 
USE COT_INT
USE UMACH_INT
 
IMPLICIT NONE
! Declare variables
INTEGER NOUT
COMPLEX VALUE, Z
! Compute
Z = (1.0, 1.0)
VALUE = COT(Z)
! Print the results
CALL UMACH (2, NOUT)
WRITE (NOUT,99999) Z, VALUE
99999 FORMAT (' COT((', F6.3, ',', F6.3, ')) = (', &
F6.3, ',', F6.3, ')')
END
Output
 
COT(( 1.000, 1.000)) = ( 0.218,-0.868)
Published date: 03/19/2020
Last modified date: 03/19/2020