一道关于牛顿迭代法的数值问题,题目是英文的,没有头绪,In celestial mechanics,Kelper `s equation is important.It reads x=y-msiny,in which x is a planet`s mean anomaly,y is eccentric anomaly,and m is the eccentricity of its orbit.T
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/11 07:33:01
一道关于牛顿迭代法的数值问题,题目是英文的,没有头绪,In celestial mechanics,Kelper `s equation is important.It reads x=y-msiny,in which x is a planet`s mean anomaly,y is eccentric anomaly,and m is the eccentricity of its orbit.T
一道关于牛顿迭代法的数值问题,题目是英文的,没有头绪,
In celestial mechanics,Kelper `s equation is important.It reads x=y-msiny,in which x is a planet`s mean anomaly,y is eccentric anomaly,and m is the eccentricity of its orbit.Taking m=0.9,construct a table of y for 30 equally spaced values of x in the interval 0
一道关于牛顿迭代法的数值问题,题目是英文的,没有头绪,In celestial mechanics,Kelper `s equation is important.It reads x=y-msiny,in which x is a planet`s mean anomaly,y is eccentric anomaly,and m is the eccentricity of its orbit.T
y-msiny-x=0,其中m=0.9,0<=x<=π,x所属区间分成30等份,对每个x用牛顿法求y.
Java代码:
public class Newton {
public static final double EPSILON = 1e-15;
private static double f(double x, double y) {
return y - 0.9 * Math.sin(y) - x;
}
// y - 0.9*Math.sin(y) - x,x取固定值,对y求导后为 1 - 0.9 * Math.cos(y)
private static double d(double y) {
return 1 - 0.9 * Math.cos(y);
}
public static double root(double x) {
double y = 1;
while (Math.abs(f(x, y) / d(y)) > EPSILON) {
y = y - f(x, y) / d(y);
}
return y;
}
public static void main(String[] args) {
double xStep = Math.PI / 30;
for (int i = 0; i <= 30; i++) {
double x = xStep * i;
double y = root(x);
System.out.println("x: " + x + ", y=: "+ y);
}
}
}