MySQL COS() Function
The COS()
function in MySQL calculates the cosine of an angle. The angle must be specified in radians.
COS(): Definition and Usage
Cosine is a fundamental trigonometric function used in various mathematical, scientific, and engineering calculations. The COS()
function makes it easy to incorporate cosine calculations into your MySQL queries. The input value represents the angle in radians, and the output is the cosine of that angle.
Syntax
Syntax
COS(number)
Parameter Values
Parameter | Description |
---|---|
number |
The angle in radians. This is required and must be a numeric value. |
Examples
Calculating the Cosine of a Number
This example calculates the cosine of 2 radians.
Syntax
SELECT COS(2);
Output
-0.416146836547142
Calculating the Cosine of Pi
This example calculates the cosine of π (pi) radians, which is -1.
Syntax
SELECT COS(PI());
Output
-1.00000000000000