Python math.atan() – Arc / Inverse Tangent

The Python programming language provides built-in and open-source libraries that can be used to perform mathematical computations. These libraries allow us to solve even the most complex problems. Some libraries include math, NumPy, pandas, SymPy, etc.

The math module provides different built-in functions to perform simple to complex tasks of math calculations.

In this Python Guide, the “math.atan()” function of the math module will be discussed in detail through appropriate examples. The following topics are elaborated on in this article:

So let’s begin!

What is Python math.atan() – Arc / Inverse Tangent?

In Python, “math.atan()” is a built-in function retrieves the arctan of a numeric value between -PI/2 and PI/2 radians. The “atan” is the inverse of “tan”. The syntax of this function will be as follows:

math.atan(value)

The parameter “value” can be any positive or negative number that will vary from negative infinity to positive infinity.

Example 1: Arc Tangent of Given Number

In the mentioned example the “math.atan()” function is used to get the arctan value of the given number.

Code:

import math

Number = 90
Output = math.atan(Number)
print('Inverse Tangent Value in radians: ',Output)

In the above code:

  • The library named “math” is imported into the program.
  • The “math.atan()” function takes a numeric value and returns the inverse tangent of that value in radians.
  • The output will be printed on the screen using the “print()” function.

Output:

The output shows the inverse tangent value of “90” in radians.

Example 2: Arc Tangent of Number in Degree

In the mentioned example, the “math.atan()” function is used to return the arctan value of the given number in “degree” using the “math.degree()” function.

Code:

import math

Number = 67
Output = math.atan(Number)
Output_Degree = math.degrees(Output)
print('Inverse Tangent Value in Degree: ', Output_Degree)

In the following code, the “math.degree()” converts the default radian value of “math.atan()” function into degree value.

Output:

The output shows the inverse tangent value of the number “67” in degree.

That’s all from this guide on Python’s “math.atan()” function!

Conclusion

In Python, the “math.atan()” takes a numeric value and retrieves the arctan or inverse tangent of the given number in radians. The retrieved value lies within the range of “-Pi/2” to “Pi/2”. The radians value returned from the “math.atan()” function can be converted into degrees using another function named “math.degree()”. This article explained Python’s “math.atan()” function with numerous examples.