C# Math.Atanh() – Examples

In this tutorial, we will learn about the C# Math.Atanh() method, and learn how to use this method to find the angle whose hyperbolic tangent is the specified number, with the help of examples.

Atanh(Double)

Math.Atanh(d) returns the angle whose hyperbolic tangent is the specified number d.

Syntax

The syntax of Atanh(Double) method is

Math.Atanh(Double d)

where

ParameterDescription
dA double value which is the hyperbolic tangent of the angle to be found out.

Return Value

The method returns a Double value .

Example 1 – Atanh()

In this example, we will give different values ranging from Negative Infinity to Positive Infinity to Atanh() method, and find the corresponding angles, in radians.

C# Program

using System;
 
class Example {
    static void Main(string[] args) {
        Double d, result;

        d = Double.NegativeInfinity;
        result = Math.Atanh(d);
        Console.WriteLine($"Atanh({d}) = {result} radians.");

        d = -5;
        result = Math.Atanh(d);
        Console.WriteLine($"Atanh({d}) = {result} radians.");

        d = -1;
        result = Math.Atanh(d);
        Console.WriteLine($"Atanh({d}) = {result} radians.");

        d = 0;
        result = Math.Atanh(d);
        Console.WriteLine($"Atanh({d}) = {result} radians.");

        d = 1;
        result = Math.Atanh(d);
        Console.WriteLine($"Atanh({d}) = {result} radians.");

        d = 5;
        result = Math.Atanh(d);
        Console.WriteLine($"Atanh({d}) = {result} radians.");

        d = Double.PositiveInfinity;
        result = Math.Atanh(d);
        Console.WriteLine($"Atanh({d}) = {result} radians.");
    }
}

Output

Atanh(-∞) = NaN radians.
Atanh(-5) = NaN radians.
Atanh(-1) = -∞ radians.
Atanh(0) = 0 radians.
Atanh(1) = ∞ radians.
Atanh(5) = NaN radians.
Atanh(∞) = NaN radians.

Conclusion

In this C# Tutorial, we have learnt the syntax of C# Math.Atanh() method, and also learnt how to use this method with the help of C# example programs.