Math.Tanh()是內置的Math類方法,該方法返回給定雙值參數的雙曲線正切。如果給定參數為NaN,則結果將為NaN。
用法:
public static double Tanh(double num)
參數:
- num:它是要返回其雙曲線tan的數字,並且此參數的類型為System.Double。
返回值:該方法返回num的雙曲正切。類型System.Double。如果num等於NegativeInfinity,則此方法返回-1。如果num等於PositiveInfinity,則此方法返回1。如果num等於NaN,則此方法返回NaN。
例子:
Input : num = 60.0 Output : 1.0
以下示例程序旨在說明Math.Tanh()方法:
示例1:
// C# program to illustrate the
// Math.Tanh()
using System;
class GFG {
// Main Method
public static void Main(String[] args)
{
double num1 = 60.0, num2 = 0.0, num3 = 1.0;
// It returns the hyperbolic tan of
// specified angle in radian
double tanhvalue = Math.Tanh(num1);
Console.WriteLine("The tanh of num1 = " + tanhvalue);
tanhvalue = Math.Tanh(num2);
Console.WriteLine("The tanh of num2 = " + tanhvalue);
tanhvalue = Math.Tanh(num3);
Console.WriteLine("The tanh of num3 = " + tanhvalue);
}
}
輸出:
The tanh of num1 = 1 The tanh of num2 = 0 The tanh of num3 = 0.761594155955765
示例2:
// C# praogram to illustrate the
// Math.Tanh() Method
using System;
class GFG {
// Main Method
public static void Main(String[] args)
{
double num1 = (30 * (Math.PI)) / 180, num2 = 11.0, num3 = 45.0;
// It returns the hyperbolic tan of
// angle in radian
double tanhvalue = Math.Tanh(num1);
Console.WriteLine("The tanh of num1 = " + tanhvalue);
tanhvalue = Math.Tanh(num2);
Console.WriteLine("The tanh of num2 = " + tanhvalue);
tanhvalue = Math.Tanh(num3);
Console.WriteLine("The tanh of num3 = " + tanhvalue);
}
}
輸出:
The tanh of num1 = 0.480472778156452 The tanh of num2 = 0.999999999442106 The tanh of num3 = 1
相關用法
- C# DateTimeOffset.Add()用法及代碼示例
- C# String.Contains()用法及代碼示例
- C# Math.Sin()用法及代碼示例
- C# Math.Cos()用法及代碼示例
- C# Dictionary.Add()用法及代碼示例
- C# Math.Tan()用法及代碼示例
- C# Math.Abs()方法用法及代碼示例
- C# Math.Exp()用法及代碼示例
- C# Math.Abs()函數用法及代碼示例
注:本文由純淨天空篩選整理自Akanksha_Rai大神的英文原創作品 C# | Math.Tanh() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。