C# Tutorial C# Advanced C# References

C# Math - Atanh() Function



The C# Atanh() function returns inverse hyperbolic tangent of a value. The inverse hyperbolic tangent of x is defined as:

Atanh

In special cases it returns the following:

  • If the argument is NaN, the method returns NaN.
  • If the absolute value of argument is greater than 1, the method returns NaN.

Syntax

public static double Atanh (double x);

Parameters

x Specify the value.

Return Value

Returns the inverse hyperbolic tangent of a value.

Example:

In the example below, Atanh() function is used to find out the inverse hyperbolic tangent of a value.

using System;

class MyProgram {
  static void Main(string[] args) {
    Console.WriteLine("Math.Atanh(-1) = "
                      + Math.Atanh(-1));
    Console.WriteLine("Math.Atanh(-0.5) = "
                      + Math.Atanh(-0.5));
    Console.WriteLine("Math.Atanh(0) = "
                      + Math.Atanh(0));
    Console.WriteLine("Math.Atanh(0.5) = "
                      + Math.Atanh(0.5));
    Console.WriteLine("Math.Atanh(1) = "
                      + Math.Atanh(1));
    Console.WriteLine("Math.Atanh(Double.NaN) = "
                      + Math.Atanh(Double.NaN));
    Console.WriteLine("Math.Atanh(Double.NegativeInfinity) = "
                      + Math.Atanh(Double.NegativeInfinity));
    Console.WriteLine("Math.Atanh(Double.PositiveInfinity) = "
                      + Math.Atanh(Double.PositiveInfinity));
  }
}

The output of the above code will be:

Math.Atanh(-1) = -Infinity
Math.Atanh(-0.5) = -0.549306144334055
Math.Atanh(0) = 0
Math.Atanh(0.5) = 0.549306144334055
Math.Atanh(1) = Infinity
Math.Atanh(Double.NaN) = NaN
Math.Atanh(Double.NegativeInfinity) = NaN
Math.Atanh(Double.PositiveInfinity) = NaN

❮ C# Math Methods