- import java.math.*;
- public class T5_12 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- /*
- * 用牛顿迭代法求方程2X*X*X-4X*X+3*X-6=0在X=1.5
- * 附近的根!
- *
- */
- double x=1.5,x0,f,f1;
- do{
- x0=x;
- f=2*x0*x0*x0-4*x0*x0+3*x0-6;
- f1=6*x0*x0-4*x0+3;
- x=x0-f/f1;
- }while(Math.abs(x-x0)>=1e-16);
- System.out.println(x0);
- }
- }