public class Main {
//本题的要求:e^ix==cosx+i*sinx
double b, c;
char i;
public static void main(String[] args) {
for(double j=0;j<90;j++){//用循环依次整出0-90度
double sum=0;//temp是e^ix;
double a=j;
a=Math.toRadians(a);//把角度转化为弧度
double b=(double)Math.cos(a);//cos()的值
double c=(double)Math.sin(a);//sin()的值
b=(double)Math.round(b * 10000)/10000;//保留四位小数
c=(double)Math.round(c * 10000)/10000;
System.out.println("exp" + "("+ "i*"+ j +")" +"="+ b +"+" + "i*"+ c);
}
}
}
代码如上,知识点有弧度转换、保留n位小数等
标签:ix,java,sinx,double,小数,public,欧拉,cosx From: https://blog.csdn.net/2301_78651392/article/details/136946100