In MariaDB, ATAN()
is a built-in numeric function that returns the arctangent (inverse tangent) of its argument.
In other words, it returns the value whose tangent is the argument.
Syntax
The syntax goes like this:
ATAN(X)
Where X
is the value for which to return the arctangent.
It can also be used with the following syntax (in which case, it does the same thing as the ATAN2()
function):
ATAN(Y,X)
When used with this syntax, it is similar to calculating the arctangent of Y / X
, except that the signs of both arguments are used to determine the quadrant of the result.
Example
Here’s an example:
SELECT ATAN(3);
Result:
+--------------------+ | ATAN(3) | +--------------------+ | 1.2490457723982544 | +--------------------+
Here are some more examples:
SELECT
ATAN(0),
ATAN(-1),
ATAN(1);
Result:
+---------+---------------------+--------------------+ | ATAN(0) | ATAN(-1) | ATAN(1) | +---------+---------------------+--------------------+ | 0 | -0.7853981633974483 | 0.7853981633974483 | +---------+---------------------+--------------------+
Two Arguments
Here’s an example of the two-argument syntax:
SELECT ATAN(2, 3);
Result:
+--------------------+ | ATAN(2, 3) | +--------------------+ | 0.5880026035475675 | +--------------------+
Non-Numeric Arguments
Here’s what happens when we provide a non-numeric argument:
SELECT ATAN('Ten');
Result:
+-------------+ | ATAN('Ten') | +-------------+ | 0 | +-------------+ 1 row in set, 1 warning (0.000 sec)
Let’s check the warning:
SHOW WARNINGS;
Result:
+---------+------+-----------------------------------------+ | Level | Code | Message | +---------+------+-----------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'Ten' | +---------+------+-----------------------------------------+
Missing Arguments
Calling ATAN()
without an argument results in an error:
SELECT ATAN();
Result:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'ATAN'