计算一个给定值的反正切
为了在 Java 中计算一个给定值的反正切,我们使用 java.lang.Math.atan() 方法。该方法接受一个双精度值,该值需要计算其角度。返回的角度范围位于 -pi/2 到 pi/2 之间。如果参数为 NaN,则结果为 NaN。
当参数为 0 时,输出为一个与参数具有相同符号的 0。
声明——java.lang.Math.atan() 方法的声明如下:
public static double atan(double a)
其中 a 是计算其反正切的值。
我们来看一个在 Java 中计算一个给定值的反正切的程序。
示例
import java.lang.Math;
public class Example {
public static void main(String[] args) {
// get two double numbers in degrees
double x = Math.sqrt(3);
double y = 1;
// computing and displaying the arc tangent of these doubles
System.out.println(“Arc tangent of " + x + " = " + Math.atan(x));
System.out.println("Arc tangent of " + y + " = " + Math.atan(y));
}
}输出
Arc tangent of 1.7320508075688772 = 1.0471975511965976 Arc tangent of 1.0 = 0.7853981633974483
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP