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

📄 d9r4.java

📁 解具有导数的多元函数的无约束极小值点或具有导数的非线性方程组的近似解
💻 JAVA
字号:
import java.text.*;
public class d9r4
{
	public static void main (String[] args)
	{
	    //program d9r4
		//driver for routine svdfit
        int i, mp, np, npt = 100;
		double chisq;
		double spread = 0.02;
		int npol = 5;
        double x[] = new double[101];
        double y[] = new double[101];
        double sig[] = new double[101];
        double a[] = new double[6];
        double cvm[] = new double[26];
        double u[] = new double[501];
        double v[] = new double[26];
        double w[] = new double[6];
		//polynomial fit
		int idum = -911;
		mp = npt;
		np = npol;
		chisq=0.0;
        d9r4F g = new d9r4F();
		DecimalFormat form = new DecimalFormat("0.000000");
        for (i = 1; i <= npt; i++)
		{
            x[i] = 0.02 * i;
            y[i] = 1.0 + x[i] * (2.0 + x[i] * (3.0 + x[i] * (4.0 + x[i] * 5.0)));
            y[i] = y[i] + spread *g.gasdev(idum);
            idum = g.gasdev_idum;
			sig[i] = spread;
		}
		g.svdfit(x, y, sig, npt, a, npol, u, v, w, mp, np, chisq, "fpoly");
        chisq = g.svdfit_chisq;
		g.svdvar(v, npol, np, w, cvm, npol);
		System.out.println();
		System.out.println("Polynomial fit");
		System.out.println();
        for (i = 1; i <= npol; i++)
		{
            System.out.print(form.format(a[i]) + "      +   -    ");
            System.out.println(form.format(Math.sqrt(cvm[(i - 1) * npol + i])) + "   ");
		}
		System.out.println();
		System.out.print("Chi-squared  ");
        System.out.println(form.format(chisq));
		g.svdfit(x, y, sig, npt, a, npol, u, v, w, mp, np, chisq, "fleg");
        chisq = g.svdfit_chisq;
		g.svdvar(v, npol, np, w, cvm, npol);
		System.out.println();
		System.out.println("Legendre polynomial fit");
        for (i = 1; i <= npol; i++)
		{
            System.out.print(form.format(a[i]) + "      +   -    "); 
            System.out.println(form.format(Math.sqrt(cvm[(i - 1) * npol + i])) + "   ");
		}
		System.out.println();
        System.out.println("Chi-squared  " + form.format(chisq));
	}
}

⌨️ 快捷键说明

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