ATAN(3) - [MATHEMATICS:TRIGONOMETRIC] Arctangent AKA inverse tangent function
result = atan([x) | atan(y, x)
elemental TYPE(kind=KIND) function atan(y,x)TYPE(kind=KIND),intent(in) :: x TYPE(kind=**),intent(in),optional :: y
o If Y is present X and Y must both be real. Otherwise, X may be complex. o KIND can be any kind supported by the associated type. o The returned value is of the same type and kind as X.
ATAN(X)(3) returns the inverse tangent (ie. arctangent) of the elements of X in radians. The function accepts both real and complex inputs, specified as a scalar, vector, matrix. The atan operation is element-wise when X is nonscalar.
When Y is not supplied the inverse tangent is defined as
o For real values of X, atan(X) returns values in the interval [-PI/2, PI/2]. o For complex values of X, atan(X) returns complex values.
i=sqrt(-1) atan(z)=>(i/2)*log(i+z/i-z).This definition of the atan function returns angles in radians within the interval [-PI/2, PI/2]. To find the four-quadrant inverse tangent, where the returned angles are in the interval [-PI, PI], use atan2.
o X : The value to compute the arctangent of. if Y is present, X shall be real. o Y : is of the same type and kind as X. If X is zero, Y must not be zero.
The returned value is of the same type and kind as X. If Y is present, the result is identical to ATAN2(Y,X). Otherwise, it is the arc tangent of X, where the real part of the result is in radians and lies in the range -PI/2 <= ATAN(X) <= PI/2
Sample program:
program demo_atan use, intrinsic :: iso_fortran_env, only : real32, real64, real128 implicit none character(len=*),parameter :: all=(*(g0,1x)) real(kind=real64),parameter :: & Deg_Per_Rad = 57.2957795130823208767981548_real64 real(kind=real64) :: x x=2.866_real64 print all, atan(x)Results:print all, atan( 2.0d0, 2.0d0),atan( 2.0d0, 2.0d0)*Deg_Per_Rad print all, atan( 2.0d0,-2.0d0),atan( 2.0d0,-2.0d0)*Deg_Per_Rad print all, atan(-2.0d0, 2.0d0),atan(-2.0d0, 2.0d0)*Deg_Per_Rad print all, atan(-2.0d0,-2.0d0),atan(-2.0d0,-2.0d0)*Deg_Per_Rad
end program demo_atan
> 1.235085437457879 > .7853981633974483 45.00000000000000 > 2.356194490192345 135.0000000000000 > -.7853981633974483 -45.00000000000000 > -2.356194490192345 -135.0000000000000
FORTRAN 77 for a complex argument; and for two arguments Fortran 2008
ATAN2(3), TAN(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
o wikipedia: inverse trigonometric functions
Nemo Release 3.1 | atan (3) | June 29, 2025 |