MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

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:

Datax
Data 1-1
Data 2-0.5
Data 30
Data 40.5
Data 51

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:

DataxATAN_Value
Data 1-1-0.7853981633974483
Data 2-0.5-0.4636476090008061
Data 300
Data 40.50.4636476090008061
Data 510.7853981633974483

Example 3:

Consider a database table called Sample with the following records:

Datayx
Data 11010
Data 2-1010
Data 310-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:

DatayxATAN_Value
Data 110100.7853981633974483
Data 2-1010-0.7853981633974483
Data 310-102.356194490192345
Data 4-10-10-2.356194490192345

❮ MariaDB Functions