How to return COTANGENT COT() values in MySQL8?

With MySQL, we can do complex calculations very easily with the help of inbuilt mathematical functions. COT(number) helps in getting the cotangent value.

Now let’s start with it.


COT(X) is a mathematical function. It returns the cotangent of number X. Where X is the argument, whose value will be passed by the user.

It returns NULL, if X is passed as NULL.

It returns Error, if any String argument or Zero is passed.


MySQL COT() : Syntax

COT ( X );

MySQL COT() : Parameter

Name, Required /Optional,Type, Description
number , Required, Double , It represents a valid number.


MySQL COT() : Output

Return, Description
NULL, if the argument is NULL.
Double, It returns arc cotangent of number.


MySQL COT()  Available from : MySQL 4.0


COT() Example 1 :

See the below example. See the output, when 12 is passed.

mysql> SELECT COT(12);
+---------------------+
| COT(12) |
+---------------------+
| -1.5726734063976893 |
+---------------------+
1 row in set (0.00 sec)

Now, Let’s change the input value to 56. See what it returns.

mysql> SELECT COT(56);
+---------------------+
| COT(56) |
+---------------------+
| -1.6359284217814665 |
+---------------------+
1 row in set (0.00 sec)

See the below value When 1 is passed as an input.

mysql> SELECT COT(1);
+--------------------+
| COT(1) |
+--------------------+
| 0.6420926159343306 |
+--------------------+
1 row in set (0.00 sec)

COT() Example 2 : Using it with PI()

We are using the PI() function to get the value of cotangent with it. I get the below value.

mysql> SELECT COT(PI());
+-----------------------+
| COT(PI()) |
+-----------------------+
| -8.165619676597685e15 |
+-----------------------+
1 row in set (0.00 sec)

COT() Example 3 : Some more examples

Below are some more examples.

mysql> SELECT COT(29.56);
+--------------------+
| COT(29.56) |
+--------------------+
| 0.2931169938865947 |
+--------------------+
1 row in set (0.00 sec)

mysql> SELECT COT(-29.56);
+---------------------+
| COT(-29.56) |
+---------------------+
| -0.2931169938865947 |
+---------------------+
1 row in set (0.01 sec)

mysql> SELECT COT(156.89);
+--------------------+
| COT(156.89) |
+--------------------+
| -5.209989733425108 |
+--------------------+
1 row in set (0.01 sec)

mysql> SELECT COT(-156.89);
+-------------------+
| COT(-156.89) |
+-------------------+
| 5.209989733425108 |
+-------------------+
1 row in set (0.00 sec)

COT() Example 3 : return ERROR if 0 is passed as an argument.

COT(0), when zero is passed as an input string it will show an error.

mysql> SELECT COT(0);
ERROR 1690 (22003): DOUBLE value is out of range in 'cot(0)'

COT() Example 4 : return error if any string argument is passed.

See the below example :

mysql> SELECT COT('test');
ERROR 1690 (22003): DOUBLE value is out of range in 'cot('test')'

mysql> SHOW ERRORS;
+-------+------+-----------------------------------------------+
| Level | Code | Message |
+-------+------+-----------------------------------------------+
| Error | 1690 | DOUBLE value is out of range in 'cot('test')' |
+-------+------+-----------------------------------------------+
1 row in set (0.00 sec)

You can see the ERROR message details with the help of the ‘SHOW ERRORS’ command. Please refer above code for the same.


COT() Example 5 : NULL arguments

If the argument is NULL, it will return NULL. See the below example :

mysql> SELECT COT(NULL);
+-----------+
| COT(NULL) |
+-----------+
| NULL |
+-----------+
1 row in set (0.00 sec)

Related articles : PI(), COS(), MySQL Maths.

jyoti rani

Recent Posts

A World of Play: The Best Toy Shopping Experience in Noida

Toys are a gateway to imagination, creativity, and learning. Whether it’s a child’s first plush toy, a set of engaging…

7 hours ago

The Ultimate Guide to Finding the Best Toy Shops in Gurgaon

Toys are more than just playthings; they help children explore, learn, and develop essential life skills. From interactive sensory toys…

1 day ago

The Ultimate Toy Shopping Guide: Finding the Best Toy Store in Noida

Toys are more than just playthings; they are tools that foster creativity, motor skills, and cognitive development in children. From…

2 days ago

Exploring the Best Toy Shop in Delhi: A Blend of Fun, Learning, and Creativity

Toys play an integral role in a child’s growth and development. They spark creativity, encourage learning, and provide endless hours…

5 days ago

What Is a Progressive Web App? Why Would You Need One?

App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…

1 year ago

7 Most Popular Paid Online Advertising Strategy

As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…

1 year ago