How to get ARC Tangent(ATAN) value in MySQL8?

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(number) is a mathematical function. It returns the arc tangent  of a number.

It returns NULL, if input is passed as NULL.

It returns Warning, if any string argument is passed.


MySQL ATAN() : Syntax

ATAN (number)

MySQL ATAN() : Parameter

Name, Required /Optional, Type, Description
number, Required, Double, It represents a valid number.


MySQL ATAN() : Output

Return, Description
NULL, if the argument is NULL.
Double, It returns the arc tangent of the input number.


MySQL ATAN()  Available from : MySQL 4.0


ATAN() Example 1 : Very Basic example

Below is a very easy example. See the value when we pass the input as 0.

mysql> SELECT ATAN(0);
+---------+
| ATAN(0) |
+---------+
| 0 |
+---------+
1 row in set (0.00 sec)

See the value when we pass the input as 1.

mysql> SELECT ATAN(1);
+--------------------+
| ATAN(1) |
+--------------------+
| 0.7853981633974483 |
+--------------------+
1 row in set (0.00 sec)

See the value when we pass the input as -1.

mysql> SELECT ATAN(-1);
+---------------------+
| ATAN(-1) |
+---------------------+
| -0.7853981633974483 |
+---------------------+
1 row in set (0.00 sec)

ATAN() Example 2 :

Below are some more examples.

mysql> SELECT ATAN(2.5);
+--------------------+
| ATAN(2.5) |
+--------------------+
| 1.1902899496825317 |
+--------------------+
1 row in set (0.00 sec)

mysql> SELECT ATAN(-2.5);
+---------------------+
| ATAN(-2.5) |
+---------------------+
| -1.1902899496825317 |
+---------------------+
1 row in set (0.00 sec)

ATAN() Example 3 : It will return Warning if any string argument is passed.

See the below example :

mysql> SELECT ATAN('test');
+--------------+
| ATAN('test') |
+--------------+
| 0 |
+--------------+
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.


ATAN() Example 4 : NULL arguments

If the argument is NULL, it will return NULL. See the below example :

mysql> SELECT ATAN(NULL);
+------------+
| ATAN(NULL) |
+------------+
| NULL |
+------------+
1 row in set (0.00 sec)

ATAN() Example 5 : Using expressions

Here are some more examples to use the expression with the ATAN() function :

mysql> SELECT ATAN(.5);
+--------------------+
| ATAN(.5) |
+--------------------+
| 0.4636476090008061 |
+--------------------+
1 row in set (0.00 sec)

Now, we will get the same value if we pass the .5 as (.2+.3). See the below screen

mysql> SELECT ATAN(.2+.3);
+--------------------+
| ATAN(.2+.3) |
+--------------------+
| 0.4636476090008061 |
+--------------------+
1 row in set (0.00 sec)

Similarly for expression (-.2+.3) = .1. You can see in the below screen that both inputs yield the same results.

mysql> SELECT (.2*.3);
+---------+
| (.2*.3) |
+---------+
| 0.06 |
+---------+
1 row in set (0.00 sec)

mysql> SELECT ATAN(.2*.3);
+---------------------+
| ATAN(.2*.3) |
+---------------------+
| 0.05992815512120788 |
+---------------------+
1 row in set (0.00 sec)

mysql> SELECT ATAN(.06);
+---------------------+
| ATAN(.06) |
+---------------------+
| 0.05992815512120788 |
+---------------------+
1 row in set (0.00 sec)

We are getting the same values when we are using expressions, rather than using the number directly.


Related articles : ABS(), ATAN2(), MySQL Maths.

jyoti rani

Recent Posts

Modern Toys, Magical Moments: Why the Best Toy Shop in Noida Is More Than Just a Store

When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…

6 months ago

Rediscovering Joy: A New Era of Creativity & Comfort in Toy Stores

In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…

6 months ago

Unboxing Imagination: Discovering the Joy of Play at a Toy Store in Noida

In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…

6 months ago

Imagination Unboxed: Discover Joy at the Toy Shop in Delhi

In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…

6 months ago

Play with Purpose: Discovering the Ultimate Toy Store in Noida

When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…

6 months ago

From Tears to Toys: Exploring Modern Childhood through Delhi’s Favorite Toy Shop

In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…

6 months ago