ATAN
The ATAN function returns the angle, expressed in radians, whose tangent is X (i.e., the arc-tangent). If two parameters are supplied, the angle whose tangent is equal to Y/X is returned.
For real input, the range of ATAN is between -∏/2 and ∏/2 for the single argument case, and between -∏ and ∏ if two arguments are given.
In the single argument case with a complex number, Z = X + iY, the complex arctangent is given by,
atan(Z) = 0.5 atan(2x, 1 - x2 - y2) + 0.25 i alog((x2 + (y+1)2)/(x2 + (y-1)2))
In the above formula, the use of the two-argument arctangent separates the solutions at X = 0 and takes into account the branch-cut discontinuity along the imaginary axis from -i∞ to -i and +i to +i∞, and ensures that tan(atan(Z)) is equal to Z 1.
In the two argument case with two complex numbers Zy and Zx, the complex arctangent is given by,
atan(Zy, Zx) = -i alog((Zx + iZy)/sqrt(Zx2 + Zy2))
In the two-argument case (either real or complex), if both arguments are zero, the result returned is platform-dependent but typically 0.
Examples
Find the angle whose tangent is 0.5 and print the result in degrees by entering:
PRINT, 180/!PI*ATAN(0.5)
IDL prints:
26.5651
Find the angle whose tangent is 0.5, taking into account that the tangent came from the ratio -0.25/-0.5:
PRINT, 180/!PI*ATAN(-0.25, -0.5)
IDL prints:
-153.435
Find the complex arccosine of 2 + i and print the result by entering:
PRINT, ATAN(COMPLEX(2,1))
IDL prints:
( 1.17810, 0.173287)
Create a visualization of the complex arctangent:
; Create a grid of complex numbers.
n = 100
x = (FINDGEN(n)-(n-1)/2.0)/(n/4)
z = DCOMPLEX(REBIN(x,n,n), REBIN(TRANSPOSE(x),n,n))
; Try any of these transcendental functions:
; ACOS, COS, COSH, ASIN, SIN, SINH,
; ATAN, TAN, TANH, ALOG, EXP
fn = ATAN(z)
ISURFACE, FLOAT(fn), x, x, COLOR=[255, 180, 0]
ISURFACE, IMAGINARY(fn), x, x, COLOR=[0, 150, 255], /OVERPLOT
Syntax
Result = ATAN(X [, /PHASE])
or
Result = ATAN(Y, X)
Return Value
Returns the angle, expressed in radians, whose tangent is X (i.e., the arc-tangent). If two parameters are supplied, the angle whose tangent is equal to Y/X is returned.
Arguments
X
The tangent of the desired angle. If X is double-precision floating or complex, the result is of the same type. All other types are converted to single-precision floating-point and yield floating-point results. If X is an array, the result has the same structure, with each element containing the arctangent of the corresponding element of X.
Y
An optional argument. If this argument is supplied, ATAN returns the angle whose tangent is equal to Y/X. If both arguments are arrays, the function matches up the corresponding elements of X and Y, returning an array with the same dimensions as the smallest array. If one argument is a scalar and the other arguments is an array, the function uses the scalar value with each element of the array, and returns an array with the same dimensions as the input array.
Keywords
PHASE
If this keyword is set, and the argument is a complex number Z, then the complex phase angle is computed as ATAN(Imaginary(Z), Real_part(Z)). If this keyword is not set, then the complex arctangent is computed as described above. If the argument is not complex or if two arguments are present, then this keyword is ignored.
Tip: Using the PHASE keyword is equivalent to computing ATAN(Imaginary(Z), Real_part(Z)), but uses less memory and is faster.
Thread Pool Keywords
This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.
Version History
Original |
Introduced |
5.6 |
Added PHASE keyword |
Resources and References
1. See formulas 4.4.37-39 in Abramowitz, M. and Stegun, I.A., 1964: Handbook of Mathematical Functions (Washington: National Bureau of Standards).