?? runge_kutta71.java.bak
字號:
//四階龍格-庫塔公式
class Runge_Kutta71{
static void RK(double a,double b,double y0,int n){
double x=a,y=y0,k1,k2,k3,k4;
double h=(b-a)/n;
int i;
System.out.print("x[0]="+a+" y[0]="+y0+"\n");
for(i=1;i<=n;i++){
k1=f(x,y);
k2=f(x+h/2,y+h*k1/2);
k3=f(x+h/2,y+h*k2/2);
k4=f(x+h,y+k3*h);
y=y+h*(k1+2*k2+2*k3+k4)/6;
x=a+i*h;
System.out.print("x["+i+"]="+x+" y["+i+"]="+y+"\n");
}
}
static double f(double x,double y){
return x*x+y*y;
}
public static void main(String[]args){
double xn=1.0;double x0=0.0;double y0=0.0;
RK(x0,xn,y0,10);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -