在 Java 中获取给定值的双曲正切
为了在 Java 中获取给定值的双曲正切,我们使用 java.lang.Math.tanh() 方法。tanh() 方法接受以弧度为单位的参数,并返回参数作为角度时的双曲正切。
声明 −java.lang.Math.tanh() 声明如下 −
public static double tanh(double x)
其中,x 为弧度为单位的角度。
我们看一个 Java 程序,用它来获取给定值的双曲正切。
示例
import java.lang.Math;
public class Example {
public static void main(String[] args) {
// get two double numbers in degrees
double x = 90;
double y = 180;
// convert them in radians
x = Math.toRadians(x);
y = Math.toRadians(y);
// computing and displaying the hyperbolic tangent of these doubles
System.out.println("Hyperbolic tangent of " + x + " = " + Math.tanh(x));
System.out.println("Hyperbolic tangent of " + y + " = " + Math.tanh(y));
}
}输出
Hyperbolic tangent of 1.5707963267948966 = 0.9171523356672744 Hyperbolic tangent of 3.141592653589793 = 0.99627207622075
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP