MathF.Tanh() Method in C# with Examples
Math.Tanh(Single) Method is the inbuilt MathF class method which returns the hyperbolic tangent of a given single value argument.
Syntax: public static float Tanh (float x);
Here, x is the number whose hyperbolic tangent is to be returned and type of this parameter is System.Single.
Return Value: This method returns the hyperbolic tangent of x of type System.Single. If x is equal to NegativeInfinity or PositiveInfinity, PositiveInfinity is returned. If x is equal to NaN, NaN is returned.
Below programs illustrate the use of the above-discussed method:
Example 1:
// C# program to illustrate the // MathF.Tanh(Single) Method using System; class GFG { // Main Method public static void Main(String[] args) { float num1 = 70.0f, num2 = 0.0f, num3 = 1.0f; // It returns the hyperbolic tangent // of specified angle in radian float tanhvalue = MathF.Tanh(num1); Console.WriteLine("The Tanh of num1 = " + tanhvalue); tanhvalue = MathF.Tanh(num2); Console.WriteLine("The Tanh of num2 = " + tanhvalue); tanhvalue = MathF.Tanh(num3); Console.WriteLine("The Tanh of num3 = " + tanhvalue); } } |
The Tanh of num1 = 1 The Tanh of num2 = 0 The Tanh of num3 = 0.7615942
Example 2:
// C# praogram to illustrate the // MathF.Tanh(Single) Method using System; class GFG { // Main Method public static void Main() { float num1 = (90 * (MathF.PI)) / 180; // calling result() method result(num1); result(Single.NaN); result(Single.NegativeInfinity); result(Single.PositiveInfinity); } // defining result() method public static void result(float value) { // using the method float result = MathF.Tanh(value); // Display the value Console.WriteLine("Tanh({0}) will be {1}", value, result); } } |
Tanh(1.570796) will be 0.9171523 Tanh(NaN) will be NaN Tanh(-Infinity) will be -1 Tanh(Infinity) will be 1
Recommended Posts:
- MathF.Log() Method in C# with Examples
- MathF.Max() Method in C# with Examples
- MathF.Pow() Method in C# with Examples
- MathF.Tan() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- MathF.Cos() Method in C# with Examples
- MathF.Sin() Method in C# with Examples
- MathF.Exp() Method in C# with Examples
- MathF.Min() Method in C# with Examples
- Stack.ToString() Method in C# with examples
- MathF.Round() Method in C# with Examples | Set - 2
- MathF.Truncate() Method in C# with Examples
- MathF.Asin() Method in C# with Examples
- Double.Equals() Method in C# with Examples
- Double.CompareTo Method in C# with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



