Site icon TestingDocs.com

MySQL Trigonometry Functions

Overview

In this tutorial, we will learn about MySQL trigonometry functions with examples. MySQL supports many in built functions.

Geometry functions

Let’s understand some basic geometry functions before trigonometry functions.

MySQL Geometry Function
Description
PI() This function returns the value of pi.
DEGREES(X)

 

This function returns the value of X, converted from radians to degrees.

radians -> degrees

RADIANS(X) This function returns the value of X, converted from degrees to radians.

degrees -> radians

 

mysql> SELECT PI();
+———-+
| PI() |
+———-+
| 3.141593 |
+———-+

mysql> SELECT DEGREES(PI());
+—————+
| DEGREES(PI()) |
+—————+
| 180 |
+—————+

MySQL Trigonometry Functions

Some of the functions are listed below:

MySQL Trigonometry Function
Description
COS(X) The function returns the cosine of X, where X is given in radians.
SIN(X)

 

The function returns the sine of X, where X is given in radians.
TAN(X)

 

The function returns the tangent of X, where X is given in radians.
COT(X)

 

The function returns the cotangent of X, where X is given in radians.
ACOS(X) This function returns the arc cosine of X, that is, the value whose cosine is X. It returns NULL if X is not in the range -1 to 1.
ASIN(X) The function returns the arc sine of X, that is, the value whose sine is X. It returns NULL if X is not in the range -1 to 1.
ATAN(X) The function returns the arc tangent of X, that is, the value whose tangent is X.
ATAN2(X,Y) The function returns the arc tangent of the two variables X and Y. The signs of both arguments are used to determine the quadrant of the result.

Examples

mysql> SELECT COS(PI()/4);
+——————–+
| COS(PI()/4) |
+——————–+
| 0.7071067811865476 |
+——————–+

mysql> SELECT TAN(PI()/4);
+——————–+
| TAN(PI()/4) |
+——————–+
| 0.9999999999999999 |
+——————–+

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version