?? sample5_3.java
字號:
/*
* 示例程序Sample5_3: NLEquations類的求非線性方程一個實根的埃特金迭代法
*/
package javaalgorithm.sample;
import javaalgorithm.algorithm.NLEquations;
import javaalgorithm.algorithm.Real;
public class Sample5_3
{
public static void main(String[] args)
{
// 建立NLEquation的子類,在其中重載函數(shù)func
class NLEq extends NLEquations
{
protected double func(double x)
{
double y = 6.0-x*x;
return y;
}
}
// 求解
NLEq nleq = new NLEq();
Real x = new Real(0.0);
if (nleq.getRootAitken(x, 60, 0.000001))
System.out.println("求得的根為:" + x);
else
System.out.println("求解失敗");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -