With MySQL, we can do complex calculations very easily with the help of inbuilt mathematical functions. ATAN() helps in getting the arc tangent of the input number. Now let’s start with these.
ATAN(B, A) and ATAN2(B, A) is a mathematical function. It returns the arc tangent of two variables .i.e A and B. It is the same as calculation B / A, except that the sign of both the argument determines the quadrant of the result.
It returns NULL, if input is passed as NULL.
It returns Warning, if any string argument is passed.
Name, Required /Optional, Type, Description
number, Required, Double, It represents a valid number.
Return, Description
NULL, if the argument is NULL.
Double, It returns the arc tangent of the input number.
Below is a very easy example. See the value when we pass the input as A as-4, B as 3. Both functions are returning the same value.
mysql> SELECT ATAN(-4,3); +---------------------+ | ATAN(-4,3) | +---------------------+ | -0.9272952180016122 | +---------------------+ 1 row in set (0.03 sec) mysql> SELECT ATAN2(-4,3); +---------------------+ | ATAN2(-4,3) | +---------------------+ | -0.9272952180016122 | +---------------------+ 1 row in set (0.00 sec)
Below are some more examples.
mysql> SELECT ATAN(PI(),-3); +-------------------+ | ATAN(PI(),-3) | +-------------------+ | 2.333143860959771 | +-------------------+ 1 row in set (0.04 sec) mysql> SELECT ATAN(8,PI()); +--------------------+ | ATAN(8,PI()) | +--------------------+ | 1.1965996462722117 | +--------------------+ 1 row in set (0.00 sec) mysql> SELECT ATAN2(PI(),-3); +-------------------+ | ATAN2(PI(),-3) | +-------------------+ | 2.333143860959771 | +-------------------+ 1 row in set (0.03 sec) mysql> SELECT ATAN2(8,PI()); +--------------------+ | ATAN2(8,PI()) | +--------------------+ | 1.1965996462722117 | +--------------------+ 1 row in set (0.00 sec)
See the below example :
mysql> SELECT ATAN('test',-3); +-------------------+ | ATAN('test',-3) | +-------------------+ | 3.141592653589793 | +-------------------+ 1 row in set, 1 warning (0.00 sec) mysql> SHOW WARNINGS; +---------+------+------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'test' | +---------+------+------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT ATAN2(5,'test'); +--------------------+ | ATAN2(5,'test') | +--------------------+ | 1.5707963267948966 | +--------------------+ 1 row in set, 1 warning (0.00 sec) mysql> SHOW WARNINGS; +---------+------+------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'test' | +---------+------+------------------------------------------+ 1 row in set (0.00 sec)
You can see the warning message with the help of the ‘SHOW WARNINGS’ command. Please refer above code for the same.
If either of the argument is NULL, it will return NULL. See the below example :
mysql> SELECT ATAN(NULL,-3); +---------------+ | ATAN(NULL,-3) | +---------------+ | NULL | +---------------+ 1 row in set (0.00 sec) mysql> SELECT ATAN(8,NULL); +--------------+ | ATAN(8,NULL) | +--------------+ | NULL | +--------------+ 1 row in set (0.00 sec) mysql> SELECT ATAN2(NULL,-8); +----------------+ | ATAN2(NULL,-8) | +----------------+ | NULL | +----------------+ 1 row in set (0.00 sec) mysql> SELECT ATAN2(6,NULL); +---------------+ | ATAN2(6,NULL) | +---------------+ | NULL | +---------------+ 1 row in set (0.00 sec)
Here are some more examples to use the expression with the ATAN() function :
mysql> SELECT ATAN(.2,.5); +--------------------+ | ATAN(.2,.5) | +--------------------+ | 0.3805063771123649 | +--------------------+ 1 row in set (0.03 sec)
With expression, it’s returning the same value as the above example.
mysql> SELECT ATAN(.1+.1,.2+.3); +--------------------+ | ATAN(.1+.1,.2+.3) | +--------------------+ | 0.3805063771123649 | +--------------------+ 1 row in set (0.03 sec)
Here are some more examples to use the expression with the ATAN2() function :
mysql> SELECT ATAN2(9,5); +--------------------+ | ATAN2(9,5) | +--------------------+ | 1.0636978224025597 | +--------------------+ 1 row in set (0.00 sec)
With expression, it’s returning the same value as the above example.
mysql> SELECT ATAN2(2+7,1+4); +--------------------+ | ATAN2(2+7,1+4) | +--------------------+ | 1.0636978224025597 | +--------------------+ 1 row in set (0.00 sec)
You can see in the below screen that both inputs yield the same results.
mysql> SELECT (.2*2),(.5*2); +--------+--------+ | (.2*2) | (.5*2) | +--------+--------+ | 0.4 | 1.0 | +--------+--------+ 1 row in set (0.00 sec) mysql> SELECT ATAN(.2*2,.5*2); +--------------------+ | ATAN(.2*2,.5*2) | +--------------------+ | 0.3805063771123649 | +--------------------+ 1 row in set (0.01 sec) mysql> SELECT ATAN2(.2*2,.5*2); +--------------------+ | ATAN2(.2*2,.5*2) | +--------------------+ | 0.3805063771123649 | +--------------------+ 1 row in set (0.01 sec)
We are getting the same values when we are using expressions, rather than using the number directly.
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…