MariaDB ATAN() Function
The MariaDB ATAN() function returns arc tangent of a number or returns the arc tangent of y and x. When using two numbers with this function, the sign of both numbers is considered to determine the quadrant for the result.
Syntax
/* arc tangent of a number */ ATAN(number) /* arc tangent of two numbers */ ATAN(y, x)
Parameters
number |
Required. Specify the number used to calculate the arc tangent. |
y, x |
Required. Specify the numbers used to calculate the arc tangent of two values. |
Return Value
Returns the arc tangent of one or two numbers.
Example 1:
The example below shows the usage of ATAN() function.
SELECT ATAN(3); Result: 1.2490457723982544 SELECT ATAN(0.5); Result: 0.4636476090008061 SELECT ATAN(0); Result: 0 SELECT ATAN(-3); Result: -1.2490457723982544 SELECT ATAN(PI(), 2); Result: 1.0038848218538872 SELECT ATAN(2, 2); Result: 0.7853981633974483 SELECT ATAN(2, -2); Result: 2.356194490192345 SELECT ATAN(-2, 2); Result: -0.7853981633974483 SELECT ATAN(-2, -2); Result: -2.356194490192345
Example 2:
Consider a database table called Sample with the following records:
Data | x |
---|---|
Data 1 | -1 |
Data 2 | -0.5 |
Data 3 | 0 |
Data 4 | 0.5 |
Data 5 | 1 |
The statement given below can be used to calculate the arc tangent of records of column x.
SELECT *, ATAN(x) AS ATAN_Value FROM Sample;
This will produce the result as shown below:
Data | x | ATAN_Value |
---|---|---|
Data 1 | -1 | -0.7853981633974483 |
Data 2 | -0.5 | -0.4636476090008061 |
Data 3 | 0 | 0 |
Data 4 | 0.5 | 0.4636476090008061 |
Data 5 | 1 | 0.7853981633974483 |
Example 3:
Consider a database table called Sample with the following records:
Data | y | x |
---|---|---|
Data 1 | 10 | 10 |
Data 2 | -10 | 10 |
Data 3 | 10 | -10 |
Data 4 | -10 | -10 |
To calculate the arc tangent of records of column y and column x, the following query can be used:
SELECT *, ATAN(y, x) AS ATAN_Value FROM Sample;
This will produce the result as shown below:
Data | y | x | ATAN_Value |
---|---|---|---|
Data 1 | 10 | 10 | 0.7853981633974483 |
Data 2 | -10 | 10 | -0.7853981633974483 |
Data 3 | 10 | -10 | 2.356194490192345 |
Data 4 | -10 | -10 | -2.356194490192345 |
❮ MariaDB Functions