📄 example4_4.java
字号:
import java.applet.*;
import java.awt.*;
public class Example4_4 extends Applet
{ public double f(double x)
{double y;
y=x*(x*x*x*x+1)-1;
return y;
}
public double lfs(double x,double eps)
{ double[] y=new double[10];
double[] a=new double[10];
int i=2,j;
a[0]=x;y[0]=f(x);y[1]=f(x+0.1);
a[1]=(y[1]-y[0])*10;
x=a[0]-y[0]/a[1];
while(i<10)
{a[i]=x;y[i]=f(x);
if(Math.abs(y[i])<eps)return x;
for(j=0;j<i;j++)a[i]=(y[i]-y[j])/(a[i]-a[j]);
x=a[i];
for(j=i-1;j>=0;j--)x=a[j]-y[j]/x;
i++;
}
return x;
}
public void paint(Graphics g)
{double x=1,y,eps=1e-7;
y=f(x);
while(y>eps){x=lfs(x,eps);y=f(x);}
g.drawString("root="+x,10,20);
g.drawString("f(x)="+y,10,40);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -