How Atand() Works in PostgreSQL

In PostgreSQL, atan() is a mathematical function that returns the angle, in degrees, whose tangent is a specified expression.

In trigonometry, this is known as the arctangent. The arctangent is the inverse of the tangent.

The arctangent is used when you know what the tangent of an angle is, but you want to know what the actual angle is.

Syntax

The syntax goes like this:

atand(x)

Where x is a double precision value that represents the tangent of the angle you’re trying to determine.

Example

Here’s an example to demonstrate how it works.

SELECT atand(1);

Result:

45

As mentioned, the argument represents the tangent, which itself can be returned with the tand() function.

Therefore, we can do the following to verify this.

SELECT atand(tand(45));

Result:

45

Fractions

The argument can contain a fractional component.

SELECT atand(1.7320508075688774);

Result:

60.00000000000001

Negative Argument

The argument can also be negative.

SELECT atand(-1.7320508075688774);

Result:

-60.00000000000001

Expressions

The argument can include expressions.

SELECT atand(.5 * .45);

Result:

12.680383491819821

Return the Angle in Radians

As mentioned, atand() returns its argument in degrees. To get it in radians, use the atan() function.

The atan() function works exactly the same as atand(), except that its argument is returned in radians instead of degrees.