COSPI(3) - [MATHEMATICS:TRIGONOMETRIC] Circular Cosine function
result = cospi(x)
elemental real(kind=KIND) function cospi(x)real(kind=KIND),intent(in) :: x
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.
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).
o X : The angle in half-revolutions to compute the cosine of.
The return value is the approximate value of the cosine of X.
The return value lies in the range -1 <= COSPI(X) <= 1 .
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_cosResults:
> 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
Fortran 2023
ACOS(3), SIN(3), TAN(3)
Fortran intrinsic descriptions
o Wikipedia:sine and cosine
Nemo Release 3.1 | cospi (3fortran) | November 02, 2024 |