# atan2

atan2(y, x)

Compute the inverse tangent of `y/x`, using the signs of both `x` and `y` to determine the quadrant of the return value.

## Examples

1. Compute the inverse tangent of a single value:

``````julia> atan2(1, 1)
0.7853981633974483``````

This example computes the inverse tangent of `1/1`, which corresponds to an angle of approximately 0.785 radians.

2. Compute the inverse tangent for multiple values:

``````julia> x = [1, -1, 0];
julia> y = [1, 1, -1];
julia> atan2.(y, x)
3-element Array{Float64,1}:
0.7853981633974483
2.356194490192345
-1.5707963267948966``````

Here, the `atan2` function is applied element-wise to compute the inverse tangent for each corresponding pair of `x` and `y` values.

3. Handle division by zero:
``````julia> atan2(0, 5)
0.0``````

When `y` is zero and `x` is non-zero, the result is always zero.

Common mistake example:

``````julia> atan2(5, 0)
ERROR: DomainError with atan2: angle is undefined for complex result``````

In this example, `x` is zero and `y` is non-zero, resulting in a domain error. It's important to avoid division by zero when using `atan2` to prevent such errors.

## See Also

acos, acosd, acosh, acot, acotd, acoth, acsc, acscd, acsch, asec, asecd, asech, asin, asind, asinh, atan, atan2, atand, atanh, cos, cosc, cosd, cosh, cospi, cot, cotd, coth, csc, cscd, csch, deg2rad, rad2deg, sin, sinc, sind, sinh, sinpi, tan, tand, tanh,

## User Contributed Notes

### Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: