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

📄 newton1.java

📁 数值算法例子,牛顿插值,拉格朗日,三次样条
💻 JAVA
字号:
/*@author 邱宇峰 ,software project031
 *2004,9,20
 */
import java.awt.*;

class newton1{
	int X;
	void action(int array[][],int count,Graphics g){
			double arrayD[]=new double[count];
			creatA cA=new creatA(count);
			arrayD=cA.creatArrayD(array);
			for(X=array[0][0];X<array[count-1][0];X++){
				for(long h=0;h<1000000;h++);
				double p=arrayD[count-1];
				for(int i=count-2;i>=0;i--){
					p=arrayD[i]+p*((double)X-(double)array[i][0]);
				}
				g.setColor(Color.yellow);
				g.drawString("*",X,(int)p);
			}
	}
}

/*this class is to calculate the constant number of 'a'
 */
 
class creatA{
	static double arrayD[];
	static int count;
	public creatA(int number){
		arrayD=new double[number];
		count=number;
	}
	
	double[] creatArrayD(int location[][]){
		for(int i=0;i<count;i++) arrayD[i]=(double)location[i][1];
		for(int i=1;i<count;i++){
			for(int j=count-1;j>=i;j--){
				arrayD[j]=((double)arrayD[j]-(double)arrayD[j-1])/((double)location[j][0]-(double)location[j-i][0]);
			}
		}
	return (arrayD);	
	}
}

⌨️ 快捷键说明

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