www.pudn.com > roll.rar > RUNGEKUT.CPP


#include "stdafx.h" 
#include  
 
void Runge_Kutta(int n,double x,double* y0,double s,double* y, 
				 void (*diffun)(double x,double* y0,double* y)) 
{ 
	int i; 
	double *k1,*k2,*k3,*k4,t; 
	k1=new double[n]; 
	k2=new double[n]; 
	k3=new double[n]; 
	k4=new double[n]; 
	diffun(x,y0,k1); 
	t=0.5*s; 
	for(i=0;ieps) return; 
		step=t; 
	} 
	while(fabs(y-yn)>eps) { 
		step=t; 
		y=yn; 
		t=0.5*step; 
		Runge_Kutta(1,x0,&y0,t,&yn,diffun); 
		if(fabs(y-yn)