Table of Contents

Function Definition: math.atan(x)

Parameters

NameTypeDescriptionExpected ValuesDefault Value
xfloatRequired. A positive or negative number. If x is not a number, it returns error a TypeErrorA positive or negative number.

Description

In this tutorial, we will learn about the Python math.atan() mathematical function. This function is an inbuilt function in Python programming language, which is used to compute the arc tangent of the given angle in radians. We will also have a look at the use cases, as well as some examples with their respective output.

Definition

Python math.atan() function is used to compute the arc tangent of the given angle in radians. It returns the arc tangent of x (x is a number) i.e., tan of x as a float value.

Usecase

The Python math.atan() function is mainly used for finding the Angle from the ratio of the opposite side and the adjacent side of the right triangle. It also helps in calculating the angle of a vector with respect to the x-axis in a two-dimensional plane.

Examples with Output

We will look at some examples of Python math.atan() function and understand how it works.

Example 1: Calculating the Arc Tangent of a number

import math 
# calculate arc tangent of 1 
x = 1

# calculate arc tangent 
y = math.atan(x) 

# print result 
print("The Arc Tangent of", x, "is", y) 

Output: The Arc Tangent of 1 is 0.7853981633974483

Example 2: Calculating the Angle of the Right Triangle Opposite Side

import math 
# sides of triangle 
a = 4 
b = 3 

# calculate ratio 
x = a / b

# calculate angle 
y = math.atan(x) 

# print result 
print("The angle of the right triangle opposite side is", y, "radians") 

Output: The angle of the right triangle opposite side is 0.9272952180016122 radians

Conclusion

We have now seen how to use the Python math.atan() function. We learned that it is used to calculate the arc tangent of a given argument in radians. We also looked at some useful examples with the respective output.

Example

There are no examples documented for this article.