Math.Tanh() Method in C#


The Math.Tanh() method in C# is used to return the hyperbolic tangent of the specified angle.

Syntax

public static double Tanh (double val);

Above, Val is the angle.

Example

Let us now see an example to implement Math.Tanh() method −

using System;
public class Demo {
   public static void Main(){
      double val1 = 30.0;
      double val2 = (60 * (Math.PI)) / 180;
      Console.WriteLine(Math.Tanh(val1));
      Console.WriteLine(Math.Tanh(val2));
   }
}

Output

This will produce the following output −

1
0.780714435359268

Example

Let us see another example to implement Math.Tanh() method −

using System;
public class Demo {
   public static void Main(){
      double val1 = 0.0;
      double val2 = 1.0;
      double val3 = 15.0;
      Console.WriteLine(Math.Tanh(val1));
      Console.WriteLine(Math.Tanh(val2));
      Console.WriteLine(Math.Tanh(val3));
   }
}

Output

This will produce the following output −

0
0.761594155955765
0.999999999999813

Updated on: 05-Nov-2019

45 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements