#include<iostream>
#include<iomanip>
#include <math.h>
using namespace std;
double f(double x,double y)
{return (y-(pow(10.0,18))/2*y);}
int main()
{double h=0.1;
double y[11],x[11];
int k;
k=pow(10.0,19);
y[0]=k;
for(int i=0; i<11;i++){x[i]=i*h;}
for(int i=0; i<11;i++)
{y[i+1]=y[i]+h*( f(x[i],y[i]) + 2*f((x[i]+h/2),(y[i]+f(x[i],y[i])/2)) + 2*f((x[i]+h/2),(y[i]+f((x[i]+h/2),(y[i]+f(x[i],y[i])/2))/2)) +
f((x[i]+h),(y[i]+f((x[i]+h/2),(y[i]+f((x[i]+h/2),(y[i]+f(x[i],y[i])/2))/2)))))/6;}
for(int i=0; i<11;i++){cout<<setw(50)<<x[i]<<setw(50)<<y[i]<<endl;}
double l=0;
cin>>l;
return 0;}
Comments
Leave a comment