#include<iostream>
#include<cmath>
#include<cstdio>
#include<iomanip>
using namespace std;
double h=0.1;//步差
double xi[]={};
double ol_yi[]={};
double gol_yi[]={};
double rk_yi[]={};
double real_yi[]={};
double f(double x,double y){
return *x/(*y*y);
}//f(x,y)
void OLFunction(){
for(int i=;i<;i++){
ol_yi[i+]=ol_yi[i]+h*f(xi[i],ol_yi[i]);
}
}//欧拉方法
void GOLFunction(){
for(int i=;i<;i++){
gol_yi[i+]=gol_yi[i]+
h*(
f(xi[i],gol_yi[i])
+f(xi[i+],gol_yi[i]+h*f(xi[i],gol_yi[i]))
)/;
}
}//改进欧拉方法
void RKFunction(){
double K1,K2,K3,K4;
for(int i=;i<;i++){
K1=f(xi[i],rk_yi[i]);
K2=f(xi[i]+h/,rk_yi[i]+h*K1/);
K3=f(xi[i]+h/,rk_yi[i]+h*K2/);
K4=f(xi[i]+h,rk_yi[i]+h*K3);
rk_yi[i+]=rk_yi[i]+h*(K1+*K2+*K3+K4)/;
}
}//经典龙格贝法
void RFunction(){
for(int i=;i<;i++){
real_yi[i]=pow(1.0+xi[i]*xi[i],/3.0);
}
}//真实解
int main(){
int i;
for(i=;i<;i++){
xi[i]=xi[i-]+h;
}//求xi[] OLFunction();//四种计算方法
GOLFunction();
RKFunction();
RFunction(); printf("-------------------------------------------------\n");
printf("xi | 欧拉 | 改进欧拉 | 经典R-K | 准确解 \n");
printf("-------------------------------------------------\n");
for(i=;i<;i++){
printf("%.1lf | %.6lf | %.6lf | %.6lf | %.8lf\n",
xi[i],ol_yi[i],gol_yi[i],rk_yi[i],real_yi[i]);
}
getchar();
return ;
}