MySQL - COT() Function



MySQL provides a set of functions to perform various numerical functions. The COT() function of MySQL is used to calculate the cotangent value of an angle.

The cotangent of an angle is defined as the ratio of the adjacent side of the given angle to the opposite side of the given angle in a right-angled triangle. This method expects a value to be passed as an argument in radians.

This function accepts an numeric value (in radians) as an argument and returns the cotangent value.

Syntax

Following is the syntax of MySQL COT() function −

COT(x);

Parameters

This function takes a numeric value representing an angle in radians as a parameter.

Return Value

This function returns the cotangent of the given angle. If the value is 0, NULL will be returned.

Example

The following query uses COT() function to calculate the cotangent of the angle 8 radians −

SELECT COT(8) As Result;

Output

This will produce the following result −

Result
-0.1470650639494805

Example

You can also pass pi() function as a value to this function as shown below. The value of PI() function is 3.14 −

SELECT COT(PI()) As Result;

Output

The output for the query above is produced as given below −

Result
-8.165619676597685e15

Example

Here, we are calculating the cotangent of the angle -16 radians −

SELECT COT(-16) As Result;

Output

This will produce the following result −

Result
-3.326323195635449

Example

If you try to retrieve the cotangent value for 0 you will get an error as shown below −

SELECT COT(0);

The output is displayed as below −

ERROR 1690 (22003): DOUBLE value is out of range in 'cot(0)'
Advertisements