Facebook Page Twitter Page LinkedIn Page
× C# Tutorial C# Advanced C# Resources


The C# Math Tanh() method returns hyperbolic tangent of a value. The hyperbolic tangent of x is defined as:

Tanh

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 example below, 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

5