MySQL ATAN() Function: Calculate inverse tangent

ATAN() converts a tangent ratio into an angle in radians. Combine it with DEGREES() for an easier-to-read angle.

ATAN(): Quick SQL Example

Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.

SELECT ROUND(DEGREES(ATAN(1)), 2) AS angle_degrees;
angle_degrees
45.00
On this page — Show page sectionsHide page sections

More SQL Examples and Explanations

ATAN(X) returns the arc tangent of X in radians.

SELECT ATAN(0); -- Output: 0
SELECT ATAN(1); -- Output: 0.785398163397448
SELECT ATAN(-2); -- Output: -1.10714871779409

Using ROUND() with ATAN()

SELECT ROUND(ATAN(-2), 2); -- Output: -1.11

Use DEGREES() to convert radians to degrees.

ATAN() with DEGREES()

SELECT DEGREES(ATAN(0)); -- Output: 0
SELECT DEGREES(ATAN(1)); -- Output: 45
SELECT DEGREES(ATAN(-1)); -- Output: -45

Syntax

SELECT ATAN(X);

How to Interpret the Result

ATAN() returns an angle between -π/2 and π/2. Use ATAN2(y, x) when the signs of both coordinates matter.

Common Question

When should I use ATAN2() instead?
ATAN2(y, x) considers both coordinates to distinguish angles in different quadrants.

Related: ACOS()

↑ Back to top




Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer