www.pudn.com > c.rar > RDROMB.C, change:1980-01-01,size:805b


/***********************龙贝格积分法*******************/ 
/********a为积分下限;b为积分上限;eps为精度要求.********/ 
#include "math.h" 
#include "stdio.h" 
double bdromb(a,b,eps) 
double a,b,eps; 
{extern double bdrombf(); 
int m,n,i,k; 
double y[10],h,ep,p,x,s,q; 
h=b-a; 
y[0]=h*(bdrombf(a)+bdrombf(b))/2.0; 
m=1;n=1;ep=eps+1.0; 
while((ep>=eps)&&(m<=9)) 
{p=0.0; 
for(i=0;i<=n-1;i++) 
{x=a+(i+0.5)*h; 
p=p+bdrombf(x); 
} 
p=(y[0]+h*p)/2.0; 
s=1.0; 
for(k=1;k<=m;k++) 
{s=4.0*s; 
q=(s*p-y[k-1])/(s-1.0); 
y[k-1]=p;p=q; 
} 
ep=fabs(q-y[m-1]); 
m=m+1;y[m-1]=q;n=n+n;h=h/2.0; 
} 
return(q); 
} 
double bdrombf(x) 
double x; 
{double y; 
y=exp(x)*x*x; 
return(y); 
} 
main() 
{double a,b,eps,t; 
a=0.0;b=1.0;eps=0.00005; 
t=bdromb(a,b,eps); 
printf("t=%e\n",t); 
} 
/***************************************/