SQL COT Function

Savigo
You organize your data. Now organize your savings.
Set savings goals, track your progress, and stay on course.
Get Savigo for iPhone 

The SQL COT function returns the cotangent of an input argument.

In math, given the ABC triangle, the cotangent of an angle (A) is defined as the ratio between the length of the adjacent side (b) to the length of the opposite side (a) as the follownig formula:

cot A = b / a
SQL_trigonometry_triangle

Syntax #

The following statement shows the syntax of the COT function.

COT(numeric_expression)

Argument #

The COT function accepts a numeric_expression that represents the angle in radians for which the cotangent is calculated. The numeric_expression must not evaluate to zero.

Return #

The COT function returns a floating-point number.

Examples #

The following example returns the cotangents of  π/6 and π/4.

SELECT COT(PI()/6) cot_one_sixth_pi, 
       COT(PI()/4) cot_one_fourth_pi;

Output:

 cot_one_sixth_pi | cot_one_fourth_pi
------------------+-------------------
 1.73205080756888 |                 1
(1 row)

Note that we use the PI function to get the π constant.

Most database systems support the COT function with the same behavior.

Was this helpful?