PostgreSQL COT() Function
The PostgreSQL COT() function returns trigonometric cotangent of an angle (angle should be in radians). The other variant of this function is COTD() which returns trigonometric cotangent of an angle (angle should be in degrees).
Syntax
/* specify angle in radians */ COT(x) /* specify angle in degrees */ COTD(x)
Parameters
x |
Required. Specify the angle. |
Return Value
Returns the trigonometric cotangent of an angle.
Example 1:
The example below shows the usage of COT() function.
SELECT COT(1); Result: 0.6420926159343306 SELECT COT(2); Result: -0.45765755436028577 SELECT COT(3); Result: -7.015252551434534 SELECT COT(-1); Result: -0.6420926159343306 SELECT COT(-2); Result: 0.45765755436028577 SELECT COT(-3); Result: 7.015252551434534 SELECT COT(PI()); Result: -8.165619676597685e+15 SELECT COT(0); Result: Infinity SELECT COTD(30); Result: 1.7320508075688774 SELECT COTD(45); Result: 1 SELECT COTD(90); Result: 0
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | 0.5 |
Data 2 | 1 |
Data 3 | 5 |
Data 4 | 10 |
Data 5 | 50 |
The statement given below can be used to calculate the trigonometric cotangent value of column x.
SELECT *, COT(x) AS COT_Value FROM Sample;
This will produce the result as shown below:
Data | x | COT_Value |
---|---|---|
Data 1 | 0.5 | 1.830487721712452 |
Data 2 | 1 | 0.6420926159343306 |
Data 3 | 5 | -0.2958129155327455 |
Data 4 | 10 | 1.5423510453569202 |
Data 5 | 50 | -3.677814450850569 |
❮ PostgreSQL Functions