C# | Método Math.Atan() – Part 1

Math.Atan() es un método de clase Math incorporado que devuelve el ángulo cuya tangente se da como un argumento de valor doble. Si el argumento es NaN , entonces el resultado será NaN .

Sintaxis:

public static double Atan(double num)

Parámetro:

num: Es el número que representa una tangente y el tipo de este parámetro es System.Double .

Tipo de retorno: Devuelve un ángulo Θ, medido en radianes y su tipo es System.Double . Aquí el ángulo siempre se mide en radianes, tal que -π/2 ≤ Θ ≤ π/2.

Ejemplos:

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

Programa: Para ilustrar el método Math.Atan()

// C# program to demonstrate working
// of Math.Atan() method
using System;
  
class Geeks {
  
    // Main Method
    public static void Main(String []args)
    {
        double a = Math.PI;
          
        // using Math.Atan() method 
        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));
  
        // Input positive zero
        // Output positive zero
        Console.WriteLine(Math.Atan(d));
  
        // Input negative zero
        // Output positive zero
        Console.WriteLine(Math.Atan(e));
          
        // input PositiveInfinity
        // Output 1.5707963267949
        Console.WriteLine(Math.Atan(posi));
          
        // input NegativeInfinity
        // Output -1.5707963267949
        Console.WriteLine(Math.Atan(nega));
          
        // input NaN
        // Output NaN
        Console.WriteLine(Math.Atan(nan));
    }
}
Producción:

1.26262725567891
0.785398163397448
0
0
1.5707963267949
-1.5707963267949
NaN

Referencia: https://msdn.microsoft.com/en-us/library/system.math.atan

Publicación traducida automáticamente

Artículo escrito por Mithun Kumar y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *