Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

ATAN


Syntax | Return Value | Arguments | Keywords | Example | Version History | See Also

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 -p/2 and p/2 for the single argument case, and between -p and p 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. For reference, see formulas 4.4.37-39 in Abramowitz, M. and Stegun, I.A., 1964: Handbook of Mathematical Functions (Washington: National Bureau of Standards).

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 then the result is undefined.

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.

Example

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) 
   oReal = OBJ_NEW('IDLgrSurface', FLOAT(fn), x, x, $ 
      COLOR=[255, 180, 0], STYLE=2) 
   oImag = OBJ_NEW('IDLgrSurface', IMAGINARY(fn), x, x, $ 
      COLOR=[0, 150, 255], STYLE=2) 
    
   ; Add graphics objects to a model and rotate to nice view. 
   oModel = OBJ_NEW('IDLgrModel') 
   oModel->Add, oReal 
   oModel->Add, oImag 
   oModel->ROTATE, [0,0,1], 25 
   oModel->ROTATE, [1,0,0], -30 
    
 
 
 
   ; Display using XOBJVIEW. 
;Block input so we can destroy objects after. 
   XOBJVIEW, oModel, /BLOCK, SCALE=1, $ 
      TITLE='Complex transcendental function', $ 
XSIZE=700, YSIZE=700 
   OBJ_DESTROY, oModel 

Version History

Introduced: Original

See Also

ACOS, COS, COSH, SIN, ASIN, SINH, TAN, TANH


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]