Math.Atan() Method in C#


The Math.Atan() method in C# is used to return the angle whose tan is the specified number. The number is a double value argument. The method returns an angle, θ, measured in radians, such that -Π/2 ≤θ≤Π/2.

Syntax

Following is the syntax −

public static double Atan(double num)

Example

Let us now see an example to implement the Math.Atan() method −

using System;
public class Demo {
   public static void Main(){
      double val1 = 0.0;
      double val2 = 1.0;
      Console.WriteLine("Return value of {0} : {1}", val1, Math.Atan(val1));
      Console.WriteLine("Return value of {0} : {1}", val2, Math.Atan(val2));
   }
}

Output

This will produce the following output −

Return value of 0 : 0
Return value of 1 : 0.785398163397448

Example

Let us see another example to implement the Math.Atan() method −

using System;
public class Demo {
   public static void Main(){
      double val1 = Double.PositiveInfinity;
      double val2 = Double.NegativeInfinity;
      Console.WriteLine("Return value of {0} : {1}", val1, Math.Atan(val1));
      Console.WriteLine("Return value of {0} : {1}", val2, Math.Atan(val2));
   }
}

Output

This will produce the following output −

Return value of ∞ : 1.5707963267949
Return value of -∞ : -1.5707963267949
raja
Published on 06-Nov-2019 06:00:11
Advertisements