C# | Math.Atan() Method
Last Updated :
31 Jan, 2019
Math.Atan() is an inbuilt Math class method which returns the angle whose tangent is given as a double value argument. If the argument is NaN, then the result will be NaN.
Syntax:
public static double Atan(double num)
Parameter:
num: It is the number that represents a tangent and type of this parameter is System.Double.
Return Type: Returns an angle Θ, measured in radians and its type is System.Double. Here the angle is always measured in radians, such that -π/2 ≤ Θ ≤ π/2.
Examples:
Input : Math.Atan(1)
Output : 0.785398163397448
Input : Math.Atan(0.0)
Output : 0
Input : Math.Atan(-0.0)
Output : 0
Input : Math.Atan(Double.PositiveInfinity)
Output : 1.5707963267949
Input : Math.Atan(Double.NegativeInfinity)
Output : -1.5707963267949
Program: To illustrate the Math.Atan() method
using System;
class Geeks {
public static void Main(String []args)
{
double a = Math.PI;
Console.WriteLine(Math.Atan(a));
double d = 0.0;
double e = -0.0;
double posi = Double.PositiveInfinity;
double nega = Double.NegativeInfinity;
double nan = Double.NaN;
Console.WriteLine(Math.Atan(1));
Console.WriteLine(Math.Atan(d));
Console.WriteLine(Math.Atan(e));
Console.WriteLine(Math.Atan(posi));
Console.WriteLine(Math.Atan(nega));
Console.WriteLine(Math.Atan(nan));
}
}
|
Output:
1.26262725567891
0.785398163397448
0
0
1.5707963267949
-1.5707963267949
NaN
Reference: https://msdn.microsoft.com/en-us/library/system.math.atan
Share your thoughts in the comments
Please Login to comment...