⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 Algorithm of Golden Ratio Method
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package labzsechenie;/** * * @author r_sattaruly */public class Main {    /**     * @param args the command line arguments     */    public static void main(String[] args) {        // TODO code application logic here        double a=-1;        double b=1;        double e=0.0001;        double t=1.618;        double x1, x2, xz;        double f1, f2, f;                x1=a+(1/(t*t))*(b-a);        x2=a+(1/t)*(b-a);        f1=(x1*x1-x1-1)/(x1*x1+x1+5);        f2=(x2*x2-x2-1)/(x2*x2+x2+5);                        while ((Math.abs(b-a))>e)        {            if(f1<f2)            {                b=x2;                x2=x1;                f2=f1;                x1=a+(1/(t*t))*(b-a);                f1=(x1*x1-x1-1)/(x1*x1+x1+5);            }            else            {                a=x1;                x1=x2;                f1=f2;                x2=a+(1/t)*(b-a);                f2=(x2*x2-x2-1)/(x2*x2+x2+5);             }                                     }        xz=(a+b)/2;        f=(xz*xz-xz-1)/(xz*xz+xz+5);        System.out.println("x* = "+xz+" f(x*) = "+f);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -