求用牛顿法解方程的代码 请大家帮忙弄个用牛顿法解方程的程序,不要说废话,只求代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private final double E = (double) 2.71828;private double f(double x) { return(x-Math.pow(E,-x)); } private double df(double x) { return(1+Math.pow(E,-x)); } private double iterate(double x) { double x1; x1=x-f(x)/df(x); return(x1); } private void newtonsMethod() { // TODO add your handling code here: final int MAXREPT = 1000; double x0,x1,eps;int k=0; double d; System.out.println("\n please input x0,eps:"); Scanner s = new Scanner(System.in); x0 = s.nextDouble(); eps = s.nextDouble(); System.out.println("\n k xk\n"); System.out.printf(" %d %f\n",k,x0); do { k++; x1=iterate(x0); System.out.printf(" %d %f\n",k,x1); d=Double.valueOf(x1-x0); x0=x1; } while((d>=eps)&(k<MAXREPT)); if(k<MAXREPT) { System.out.printf("the root is x=%f, k=%d\n",x1,k); }else{ System.out.printf("\n The iteration is failed!\n"); } } 把上面给的代码放入你自己的class,然后调用其函数就行了。 不显示删除回复显示所有回复显示星级回复显示得分回复 这段代码的简单的类图设计如图以及对象协作图 请问将int[]={1,2,3}转换为String java程序怎么部署 菜鸟求助:逻辑强的大侠们请进。。。 关于JBuilder 9 注册的问题(谢谢各位了!!新年好!!!) 【飞加Java学习笔记_多线程_生产者消费者】 java服务器和C语言客户端的问题 我用的是oracle jDeveloper 9.03,怎样把jdk1.3升为1.4? 请问下面这个小程序错在什么地方?谢谢! 求高手点拨一个:“Java Swing的皮肤包的修改”“所需要阅读的指导教程”。 万分感谢 有关软件加密的问题
{
return(x-Math.pow(E,-x));
} private double df(double x)
{
return(1+Math.pow(E,-x));
} private double iterate(double x)
{
double x1;
x1=x-f(x)/df(x);
return(x1);
}
private void newtonsMethod() {
// TODO add your handling code here:
final int MAXREPT = 1000;
double x0,x1,eps;int k=0;
double d;
System.out.println("\n please input x0,eps:");
Scanner s = new Scanner(System.in);
x0 = s.nextDouble();
eps = s.nextDouble();
System.out.println("\n k xk\n");
System.out.printf(" %d %f\n",k,x0);
do
{
k++;
x1=iterate(x0);
System.out.printf(" %d %f\n",k,x1);
d=Double.valueOf(x1-x0);
x0=x1;
} while((d>=eps)&(k<MAXREPT));
if(k<MAXREPT) {
System.out.printf("the root is x=%f, k=%d\n",x1,k);
}else{
System.out.printf("\n The iteration is failed!\n");
}
}