COSPI (The GNU Fortran Compiler)

### 8.82 `COSPI` — Circular cosine function ¶

Description:

  `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)`.

Standard:

  Fortran 2023

Class:

  Elemental function

Syntax:

  `RESULT = COSPI(X)`

Arguments:

  X | The type shall be `REAL`.

Return value:

  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.

Example:

      program test_cospi
        real :: x = 0.0
        x = cospi(x)
      end program test_cospi

See also:

  `ACOSPI` — Circular arc cosine function
  `COS` — Cosine function