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

📄 subsectionintegral.java

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

public class subsectionIntegral extends Frame implements ActionListener{
	static subsectionIntegral frm=new subsectionIntegral();
	static Button b1;
	static Panel pl;
	static Label l;
	static TextField tf;
	public static void main(String[] args){
		pl=new Panel();
		pl.setLayout(new FlowLayout());
		frm.setTitle("拉格朗日逼近法");
		b1=new Button("start");
		l=new Label("Current acreage is");
		tf=new TextField(20);
		pl.add(b1);
		pl.add(l);
		pl.add(tf);
		frm.add(pl,"South");
		frm.setSize(800,500);
 		frm.setLocation(200,200);
		frm.setVisible(true);
		b1.addActionListener(frm);
 		frm.addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}
		});
	}
	public void paint(Graphics g){
		double X,Y;
		int x=0;
		g.drawLine(80,300,750,300);
		g.drawLine(90,150,90,300);
		g.drawString("0",90,310);
		g.drawString("5",590,310);
		for(X=0;X<5;X+=0.01){
			Y=Math.sin(X)*Math.sin(X)+1;
			g.drawString(".",90+x,300-(int)(100*Y));
			x++;
		}
	}
	public void actionPerformed(ActionEvent ae){
		Graphics g=getGraphics();
		g.drawString("Processing...",50,100);
		boolean continueDo=true,continueDo1=true;
		int I=0;
		double []stack=new double[200];
		double a=0.0,b=5.0,e=0.00001,u,v,w,T0,T1=0,h,S=0;
		e=e/(b-a);
		u=a;v=b;
		while(continueDo){
			while(continueDo1){
				for(int i=0;i<600000;i++);
				h=v-u;
				T0=h*((Math.sin(u)*Math.sin(u)+1)+(Math.sin(v)*Math.sin(v)+1))/2;
				w=(u+v)/2;
				T1=T0/2+h/2*(Math.sin(w)*Math.sin(w)+1);
				if(Math.abs(T1-T0)<(h*e)) continueDo1=false;
				else{
					I++;
					stack[I]=v;
					v=w;
				}
				g.setColor(Color.red);
				g.drawLine(90+(int)(w*100),300,90+(int)(w*100),300-(int)(100*(Math.sin(w)*Math.sin(w)+1)));	
			}
			S=S+T1;
			tf.setText(""+S);
			if(I==0) continueDo=false;  
			else{
				u=v;
				v=stack[I];
				I--;
				continueDo1=true;
			}
		}
		g.drawString("End",150,100);
	}
}

⌨️ 快捷键说明

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