Home >>Python math Module >Python math.atan2() Method

Python math.atan2() Method

Python math.atan2() Method

Python math.atan2() Methodis used to get the arc tangent value of y/x and it accepts two numbers (return is between PI and -PI) and returns arc tangent.

Syntax:
math.atan2(y,x)

Parameter Values

Parameter Description
y It is Required and specifies the dividend
x It is Required and specifies the divisor
Here is an Example of Python math.atan2() Method:

import math
print (math.atan2(3, 9))
print (math.atan2(17, 5))
print (math.atan2(13, -2))

Output:
0.3217505543966422
1.2847448850775784
1.7234456551901618
Example 2:

import math
x = -1
y = 1
print("atan2(",x,",",y,") is = ", math.atan2(x,y))
x = 0.1674
y = 1.895
print("atan2(",x,",",y,") is = ", math.atan2(x,y))
x = -2
y = 2
print("atan2(",x,",",y,") is = ", math.atan2(x,y))
x = 5
y = 34.12
print("atan2(",x,",",y,") is = ", math.atan2(x,y))

Output:
atan2( -1 , 1 ) is = -0.7853981633974483
atan2( 0.1674 , 1.895 ) is = 0.08810901801194537
atan2( -2 , 2 ) is = -0.7853981633974483
atan2( 5 , 34.12 ) is = 0.14550596282086034

No Sidebar ads