SQLite COS() Function
The SQLite COS() function returns trigonometric cosine of an angle (angle should be in radians).
Syntax
COS(x)
Parameters
x |
Required. Specify the angle in radian. |
Return Value
Returns the trigonometric cosine of an angle.
Example 1:
The example below shows the usage of COS() function.
SELECT COS(0); Result: 1.0 SELECT COS(1); Result: 0.54030230586814 SELECT COS(-1); Result: 0.54030230586814 SELECT COS(2); Result: -0.416146836547142 SELECT COS(-2); Result: -0.416146836547142 SELECT COS(PI()); Result: -1.0
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | -10 |
Data 2 | -5 |
Data 3 | 0 |
Data 4 | 5 |
Data 5 | 10 |
The statement given below can be used to calculate the trigonometric cosine value of column x.
SELECT *, COS(x) AS COS_Value FROM Sample;
This will produce the result as shown below:
Data | x | COS_Value |
---|---|---|
Data 1 | -10 | -0.839071529076452 |
Data 2 | -5 | 0.283662185463226 |
Data 3 | 0 | 1.0 |
Data 4 | 5 | 0.283662185463226 |
Data 5 | 10 | -0.839071529076452 |
❮ SQLite Functions