The ATAN() function in SQLite calculates the arc tangent (inverse tangent) of a given numeric value. The result is the angle in radians whose tangent is the specified number.
Syntax
ATAN(X)
Where X is the numeric value for which you want to calculate the arc tangent. This value can be any real number (positive, negative, or zero).
The result will be an angle in radians between -π/2 and π/2 (approximately -1.5708 and 1.5708).
Example 1
Here’s a quick example to demonstrate how it works:
SELECT ATAN(5);
Output:
1.37340076694502
Example 2
Suppose we have a table angles with a column tan_value that contains tangent values, and we want to find the corresponding angle in radians for these values.
CREATE TABLE angles (tan_value REAL);
INSERT INTO angles (tan_value) VALUES (1), (0.5), (0), (-0.5), (-1);
Now, we can use ATAN() to calculate the angle in radians for each tangent value:
SELECT tan_value, ATAN(tan_value) AS angle_in_radians
FROM angles;
Output:
tan_value angle_in_radians
--------- ------------------
1.0 0.785398163397448
0.5 0.463647609000806
0.0 0.0
-0.5 -0.463647609000806
-1.0 -0.785398163397448
In this example:
- When
tan_valueis1, the result is approximately0.785398163397448radians (π/4), since the tangent of π/4 is 1. - When
tan_valueis0.5, the angle is approximately0.463647609000806radians. - When
tan_valueis0, the angle is0radians because the tangent of0radians is0. - When
tan_valueis-0.5, the angle is approximately-0.463647609000806radians. - Similarly,
-1corresponds to approximately-0.785398163397448radians.
The ATAN() function is commonly used in trigonometry and geometry, especially when converting a tangent value back to an angle, such as in navigation, physics, and engineering calculations.