MySQL ATAN() Function
The ATAN()
function in MySQL calculates the arctangent (inverse tangent) of a number. The arctangent is the angle whose tangent is equal to the given number. The result is an angle expressed in radians.
ATAN(): Definition and Usage
ATAN()
has two forms: one that takes a single number and another that takes two numbers. The single-number form calculates the arctangent of that number. The two-number form calculates the arctangent of the ratio of the two numbers, providing a more versatile way to compute angles, especially when dealing with Cartesian coordinates (x, y).
Syntax
Syntax
ATAN(number) -- Single-number form
ATAN(a, b) -- Two-number form
Parameter Values
Parameter | Description |
---|---|
number |
A numeric value representing the tangent of an angle (single-number form). |
a, b |
Two numeric values; the arctangent of (a/b) is calculated (two-number form). |
Examples
Arctangent of a Single Number
This example finds the arctangent of 2.5.
Syntax
SELECT ATAN(2.5);
Output
1.19028994968263 (Result in radians)
Arctangent of Two Numbers
This example demonstrates the two-number form. The arctangent of (-0.8/2) is calculated.
Syntax
SELECT ATAN(-0.8, 2);
Output
-0.38050637711219 (Result in radians)