# Python math.atan2() – Arc / Inverse Tangent of (y / x)

Contents

## Python math.atan2()

math.atan2() function takes two arguments: x, y; and returns the inverse tangent of (y / x).

The return value is angle in radians.

### Syntax

The syntax to call atan2() function is

math.atan2(y, x)

where

### Examples

In the following example, we find the inverse tangent for the arguments: y=10, x=3; using atan2() function of math module.

Python Program

import math

y = 10
x = 3
result = math.atan2(y, x)
Run Code Copy

Output

We can convert the returned radians into degrees using math.degrees() function.

In the following example, we find the inverse tangent for the arguments: y=10, x=3; using atan2() function and convert this returned radians to degrees.

Python Program

import math

y = 10
x = 3
result = math.atan2(y, x)
result = math.degrees(result)
print('atan2(y, x) :', result, 'degrees')
Run Code Copy

Output

atan2(y, x) : 73.30075576600639 degrees

Let us take the value of infinity for y, and find the value of atan2(y, x).

Python Program

import math

y = math.inf
x = 3
result = math.atan2(y, x)
result = math.degrees(result)
print('atan2(y, x) :', result, 'degrees')
Run Code Copy

Output

atan2(y, x) : 90.0 degrees

### Summary

In this Python Examples tutorial, we learned the syntax of, and examples for math.atan2() function.

## Related Tutorials

Code copied to clipboard successfully 👍