In PostgreSQL, tan()
is a mathematical function that returns the tangent of the input expression.
The input expression is provided as an argument, and it is specified in degrees.
In trigonometry, in a right-angled triangle, the tangent of an angle is the length of the opposite side divided by the length of the adjacent side.
Syntax
The syntax goes like this:
tand(x)
Where x
is a double precision value that is interpreted as number of radians.
Example
Here’s an example to demonstrate how it works.
SELECT tand(45);
Result:
1
Fractions
The argument can contain a fractional component.
SELECT tand(63.435);
Result:
2.0000044660505405
Negative Argument
The argument can also be negative.
SELECT tand(-63.435);
Result:
-2.0000044660505405
Expressions
The argument can include expressions.
SELECT tand(20 * 3);
Result:
1.7320508075688774
Specify the Angle in Radians
As mentioned, tand()
accepts its argument in degrees. To provide it in radians, use the tan()
function.
The tan()
function works exactly the same as tand()
, except that its argument is specified in radians instead of degrees.