[ Arithmetic | Reference Manual | Alphabetic Index ]

atan(+Y, +X, -Result)

-Result is atan(+Y, +X)

Computes the arc tangent function of two variables and unifies the resulting value with Result.
Y
A number.
X
A number.
Result
Output: float or breal.

Description

Computes the arc tangent function of two variables and unifies the resulting value with Result.

It is similar to calculating the arc tangent of Y/X, except that the signs of both arguments are used to determine the quadrant of the result. The result lies in the interval -pi..pi. The operation is valid even if X is zero, in which case the result is pi/2 or -pi/2. One application is the conversion of cartesian to polar coordinates, where this function computes the angle component (in radians).

This predicate can be used as a function in arithmetic expressions. In coroutining mode, if X or Y is uninstantiated, the call to atan/3 is delayed until both variables are instantiated.

Modes and Determinism

Exceptions

(4) instantiation fault
X or Y is not instantiated (non-coroutining mode only).
(24) number expected
Number is not of a numeric type.

Examples

Success:
    Result is atan( 0.0, -1.0).		% gives Result =  3.141592
    Result is atan( 1.0, -1.0).		% gives Result =  2.356194
    Result is atan( 1.0,  0.0).		% gives Result =  1.570796
    Result is atan( 1.0,  1.0).		% gives Result =  0.785398
    Result is atan( 0.0,  0.0).		% gives Result =  0.0
    Result is atan(-1.0,  1.0).		% gives Result = -0.785398
    Result is atan(-1.0,  0.0).		% gives Result = -1.570796
    Result is atan(-1.0, -1.0).		% gives Result = -2.356194
    Result is atan(-0.0, -1.0).		% gives Result = -3.141592

    Result is atan( 7.0,  7.0).		% gives Result =  0.785398

See Also

is / 2