COSPI
— Circular cosine function ¶COSPI(X)
computes \cos(\pi x) without performing
an explicit multiplication by \pi. This is achieved
through argument reduction where x = n + r with
n an integer and 0 \leq r \le 1.
Due to the
properties of floating-point arithmetic, the useful range
for X is defined by
ABS(X) <= REAL(2,KIND(X))**DIGITS(X)
.
Fortran 2023
Elemental function
RESULT = COSPI(X)
X | The type shall be REAL . |
The return value is of the same type and kind as X. The result is in half-revolutions and satisfies -1 \leq \cospi (x) \leq 1.
program test_cospi real :: x = 0.0 x = cospi(x) end program test_cospi