C# - Math Tanh() Method
The C# Math Tanh() method is used to return hyperbolic tangent of a value. The hyperbolic tangent of x is defined as:
where e is an Euler's number.
In special cases it returns the following:
- If the argument is NaN, the method returns NaN.
- If the argument is PositiveInfinity, the method returns 1.
- If the argument is NegativeInfinity, the method returns -1.
Syntax
public static double Tanh(double arg);
Parameters
arg |
Specify the value. |
Return Value
Returns the hyperbolic tangent of a value.
Example:
In the below example, Tanh() method is used to find out the hyperbolic tangent of a value.
using System; class MyProgram { static void Main(string[] args) { Console.WriteLine(Math.Tanh(0)); Console.WriteLine(Math.Tanh(2)); Console.WriteLine(Math.Tanh(4)); } }
The output of the above code will be:
0 0.964027580075817 0.999329299739067
❮ C# Math Methods