SIN() and COS() Function in MySQL
1. SIN() Function :
SIN() function in MySQL is used to return the sine of any given number X, where X is given in radians.
Syntax :
SIN(X)
Parameter : Required.
X : A number whose sine value we want to calculate. It is given in radian.
Returns : It returns the sine of given number x.
Example-1 :
Sine of 0 using SIN() function.
SELECT SIN(0) AS Sin_Val;
Output :
Sin_Val |
---|
0 |
Example-2 :
Sine of 90 degree i.e 1.5707963267948966 radian using SIN() function.
SELECT SIN(1.5707963267948966) AS Sin_Val;
Output :
Sin_Val |
---|
1 |
Example-3 :
Sine of -90 degree i.e -1.5707963267948966 radian using SIN() function.
SELECT SIN(-1.5707963267948966) AS Sin_Val;
Output :
Sin_Val |
---|
-1 |
Example-4 :
Sine value of a numeric column in a table.
Table – Number
X |
---|
-1.22 |
-0.5 |
0 |
0.54 |
1.55 |
SELECT X, SIN(X) AS Sin_X FROM Number;
Output :
X | Sin_X |
---|---|
-1.22 | -0.9390993563190676 |
-0.5 | -0.479425538604203 |
0 | 0 |
0.54 | 0.5141359916531132 |
1.55 | 0.999783764189357 |
2. COS() Function :
COS() function in MySQL is used to return the cosine of any given number X, where X is given in radians.
Syntax :
COS(X)
Parameter : Required.
X : A number whose co-sine value we want to calculate. It is given in radian.
Returns : It returns the cosine of given number x.
Example-1 :
Co-Sine of 0 using COS() function.
SELECT COS(0) AS Cos_Val;
Output :
Cos_Val |
---|
1 |
Example-2 :
Co-Sine of 90 degree i.e 1.5707963267948966 radian using COS() function.
SELECT COS(1.5707963267948966) AS Cos_Val;
Output :
Cos_Val |
---|
0 |
Example-3 :
Co-Sine value of a numeric column in a table.
Table – Number
X |
---|
-1.22 |
-0.5 |
0 |
0.25 |
1.55 |
SELECT X, COS(X) AS Cos_X FROM Number;
Output :
X | Cos_X |
---|---|
-1.22 | 0.34364574631604705 |
-0.5 | 0.8775825618903728 |
0 | 1 |
0.25 | 0.9689124217106447 |
1.55 | 0.020794827803092428 |
Please Login to comment...