Manual Reference Pages  - cospi (3fortran)

NAME

COSPI(3) - [MATHEMATICS:TRIGONOMETRIC] Circular Cosine function

SYNOPSIS

result = cospi(x)

         elemental real(kind=KIND) function cospi(x)

real(kind=KIND),intent(in) :: x

CHARACTERISTICS

o X is of type real.
o KIND may be any kind supported by the associated type of X.
o The returned value will be of the same type and kind as the argument X.

DESCRIPTION

COSPI(3) computes the circular cosine of an angle X given the size of the angle in half-revolutions.

The cosine of a real value is the ratio of the adjacent side to the hypotenuse of a right-angled triangle.

COSPI(X) is approximately equal to COS(X*PI).

OPTIONS

o X : The angle in half-revolutions to compute the cosine of.

RESULT

The return value is the approximate value of the cosine of X.

The return value lies in the range -1 <= COSPI(X) <= 1 .

EXAMPLES

Example: COSPI(1.0) has the value -1.0 (approximately).

Sample program:

    program demo_cos
    implicit none
    character(len=*),parameter :: g2=’(a,t21,*(g0,1x))’
       write(*,g2) ’Basics:’
       write(*,g2) ’COSpi(0)=’,      cospi(0.0d0)
       write(*,g2) ’COSpi(1)=’,      cospi(1.0d0)
       write(*,g2) ’COSpi(1/2)=’,    cospi(1.0d0/2.0d0)
       write(*,g2) ’COSpi(2)=’,      cospi(2.0d0)
       write(*,g2) ’COSpi(-2)=’,     cospi(-2.0d0)
       write(*,g2) ’COSpi(-2000)=’,  cospi(-2000.0d0)
       write(*,g2) ’COSpi(3000)=’,   cospi(3000.0d0)
       write(*,g2) ’Elemental:’
       write(*,g2) ’COSpi([0,1/4,-1/4])=’,COSpi([0.0,0.25,-0.25])
    end program demo_cos

Results:

     > Basics:
     > COSpi(0)=           1.0000000000000000
     > COSpi(1)=           -1.0000000000000000
     > COSpi(1/2)=         0.61232339957367660E-16
     > COSpi(2)=           1.0000000000000000
     > COSpi(-2)=          1.0000000000000000
     > COSpi(-2000)=       1.0000000000000000
     > COSpi(3000)=        1.0000000000000000
     > Elemental:
     > COSpi([0,1/4,-1/4])=1.00000000 0.707106769 0.707106769

STANDARD

Fortran 2023

SEE ALSO

ACOS(3), SIN(3), TAN(3)

RESOURCES

o Wikipedia:sine and cosine
Fortran intrinsic descriptions


Nemo Release 3.1 cospi (3fortran) November 02, 2024
Generated by manServer 1.08 from 2965c787-8e4a-4aed-b80b-ab0e591b285e using man macros.