# atan2() Function & Examples

Use the atan2() trigonometry function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## atan2

#### atan2(y, x)

Try it yourself:

```calculio
atan2(2, 2) / pi
angle = 60 deg in rad
x = cos(angle)
y = sin(angle)
atan2(y, x)
```

[sin](https://calcul.io/function/sin/index.md)

[cos](https://calcul.io/function/cos/index.md)

[tan](https://calcul.io/function/tan/index.md)

---

## atan2(): A Quadrant-Aware Angle from Coordinates

**atan2(y, x)** returns the angle of the coordinate pair (x, y) from the positive x-axis. It is the preferred way to calculate a direction, heading, or phase because it uses both components rather than only their quotient. The result normally lies on the principal interval from −π to π.

## Why atan2 beats atan(y/x)

Dividing y by x before using [atan()](https://calcul.io/function/atan/index.md) loses whether both signs were reversed, so it cannot distinguish opposite quadrants. It also fails when x is zero. atan2 retains the signs of both inputs and correctly places a vector in its quadrant, including vertical directions.

For example, atan2(1, 0) is π/2, atan2(0, -1) is π, and atan2(-1, 0) is −π/2. The pair (0, 0) has no geometric direction, so treat that case explicitly in an application such as navigation or vector normalization.

## Common applications

atan2 is used to point an object toward a target, calculate a bearing from coordinate differences, derive phase from real and imaginary signal parts, and convert Cartesian coordinates into polar form. Combine it with [hypot()](https://calcul.io/function/hypot/index.md) for a stable magnitude, or with [abs()](https://calcul.io/function/abs/index.md) for a complex number’s magnitude.

For complex values, [arg()](https://calcul.io/function/arg/index.md) expresses the same direction concept directly. To convert an atan2 result back into components, use [cos()](https://calcul.io/function/cos/index.md) and [sin()](https://calcul.io/function/sin/index.md) with the radius. Keep all angles in radians until display conversion.

[All functions](https://calcul.io/functions/index.md)
