Python | PyTorch atan() method Last Updated : 06 Jan, 2022 Comments Improve Suggest changes Like Article Like Report PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.atan() provides support for the inverse tangent function in PyTorch. It gives the output in radian form. The input type is tensor and if the input contains more than one element, element-wise inverse tangent is computed. Syntax: torch.atan(x, out=None) Parameters: x: Input tensor name (optional): Output tensor Return type: A tensor with the same type as that of x. Code #1: Python3 # Importing the PyTorch library import torch # A constant tensor of size 6 a = torch.FloatTensor([1.0, -0.5, 3.4, 0.2, 0.0, -2]) print(a) # Applying the inverse tan function and # storing the result in 'b' b = torch.atan(a) print(b) Output: tensor([ 1.0000, -0.5000, 3.4000, 0.2000, 0.0000, -2.0000]) tensor([ 0.7854, -0.4636, 1.2847, 0.1974, 0.0000, -1.1071]) Code #2: Visualization Python3 # Importing the PyTorch library import torch # Importing the NumPy library import numpy as np # Importing the matplotlib.pyplot function import matplotlib.pyplot as plt # A vector of size 15 with values from -5 to 5 a = np.linspace(-5, 5, 15) # Applying the inverse tangent function and # storing the result in 'b' b = torch.atan(torch.FloatTensor(a)) print(b) # Plotting plt.plot(a, b.numpy(), color = 'red', marker = "o") plt.title("torch.atan") plt.xlabel("X") plt.ylabel("Y") plt.show() Output: tensor([-1.3734, -1.3416, -1.2978, -1.2341, -1.1342, -0.9601, -0.6202, 0.0000, 0.6202, 0.9601, 1.1342, 1.2341, 1.2978, 1.3416, 1.3734]) Comment More infoAdvertise with us Next Article Python | PyTorch acos() method V vaibhav29498 Follow Improve Article Tags : Python Practice Tags : python Similar Reads Python - PyTorch atan2() method PyTorch atan2() method computes element-wise arctangent of (y/x), where y, x are the tensors with y-coordinates and x-coordinates of the points respectively. The arctangent of (y/x) is the angle between the positive x-axis and the line from (0,0) to the (x,y). So the atan2() method computes these an 4 min read Python | PyTorch asin() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.The function torch.asin() provides support for the inverse sine function in PyTorch. It expects the input to be in the range [-1, 1] and gives the out 2 min read Python | PyTorch acos() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.acos() provides support for the inverse cosine function in PyTorch. It expects the input to be in the range [-1, 1] and gives the 2 min read Python | PyTorch cos() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes.The function torch.cos() provides support for the cosine function in PyTorch. It expects the input in radian form and the output is in the range [-1, 2 min read Python | PyTorch cosh() method PyTorch is an open-source machine learning library developed by Facebook. It is used for deep neural network and natural language processing purposes. The function torch.cosh() provides support for the hyperbolic cosine function in PyTorch. It expects the input in radian form. The input type is tens 2 min read Python | sympy.atan() method In sympy, atan() method is an inverse tangent function. Using the atan(x) method in the sympy module, we can compute the inverse tangent or arctangent of x. Syntax : sympy.atan(x) Return : Returns the arc tangent of x Code #1: Below is the example using atan() method to find the inverse tangent func 1 min read Like