math.atan2()
Published Sep 18, 2024
Contribute to Docs
The math.atan2()
function in Python takes two numeric values representing a point (x, y)
and returns a float that represents the arc tangent of y
divided by x
. The resulting value is in radians and ranges from -π
to π
.
Syntax
math.atan2(y, x)
y
: A numeric value representing they
coordinate of the point.x
: A numeric value representing thex
coordinate of the point.
Note: The function takes the y-coordinate (
y
) as the first parameter and the x-coordinate (x
) as the second.
Example
In the example below, the math.atan2()
function is used to return the arc tangent of a point (5, 6)
:
import mathprint(math.atan2(6, 5))
The above code gives the following output:
0.8760580505981934
Codebyte Example
The following codebyte example demonstrates how the math.atan2()
function works:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.