.Tanh()

Published Apr 10, 2023Updated Sep 1, 2023
Contribute to Docs

The Math.Tanh() method returns the hyperbolic tangent of a given angle in radians.

Syntax

Math.Tahn(x);

This method accepts a single parameter,x, which is the angle in radians. It returns the hyperbolic tangent value of x.

Example

The example below declares two double values, x and y, and then calculates the hyperbolic tangent of x using the Math.Tanh() function. The resulting value is stored in y. Finally, the value of y is printed to the console.

using System;
public class Program
{
public static void Main()
{
double x = 2;
double y = Math.Tanh(x);
Console.WriteLine(y);
// Output: 0.9640275800758169
}

Codebyte Example

This example is runnable and demonstrates the Math.tanh() function:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn C# on Codecademy