C# .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:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C# on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.
- Beginner Friendly.15 hours