|
楼主 |
发表于 2005-1-19 22:52:49
|
显示全部楼层
<>//有理分式法计算二重积分
//a-积分下限
//b-积分上限,要求b>a
//eps-积分精度要求
//bjpqf-积分函数
//bjpqfs-计算积分上下限y1(x),y0(x).要求y1(x)>y0(x),
//其中参数y[0]返回y0(x)的值,参数y[1]返回y1(x)的值
//调用函数 ppg1()
static double pqg1(double x,double eps,double (*bjpqf)(double,double),void (*bjpqfs)(double,double*));
double bjpq(double a,double b,double eps,double (*bjpqf)(double,double),void (*bjpqfs)(double,double*))
{
int m,n,k,l,j;
double bb[10],h[10],hh,s1,s2,t1,t2,x,g,s0,ep,s;
m=1;
n=1;
hh=b-a; h[0]=hh;
s1=pqg1(a,eps,bjpqf,bjpqfs);
s2=pqg1(b,eps,bjpqf,bjpqfs);
t1=hh*(s1+s2)/2.0;
s0=t1;
bb[0]=t1;
ep=1.0+eps;
while ((ep>=eps)&&(m<=9))
{
t2=0.5*t1;
for (k=0;k<=n-1;k++)
{
x=a+(k+0.5)*hh;
s1=pqg1(x,eps,bjpqf,bjpqfs);
t2=t2+0.5*s1*hh;
}
m=m+1;
h[m-1]=h[m-2]/2.0;
g=t2;
l=0;
for (j=2;j<=m;j++)
{
s=g-bb[j-2];
if (l==0)
if (fabs(s)+1.0==1.0)
{
l=1;
}
else
{
g=(h[m-1]-h[j-2])/s;
}
}
bb[m-1]=g;
if (l!=0)
{
bb[m-1]=1.0e+35;
}
s=bb[m-1];
for (j=m;j>=2;j--)
{
s=bb[j-2]-h[j-2]/s;
}
ep=fabs(s-s0)/(1.0+fabs(s));
n=n+n;
t1=t2;
s0=s;
hh=hh/2.0;
}
return(s);
}</P><>static double pqg1(double x,double eps,double (*bjpqf)(double,double),void (*bjpqfs)(double,double*))
{
int m,n,k,l,j;
double b[10],h[10],y[2],hh,t1,t2,s0,yy,g,ep,s;
m=1; n=1;
bjpqfs(x,y);
hh=y[1]-y[0];
h[0]=hh;
t1=0.5*hh*(bjpqf(x,y[0])+bjpqf(x,y[1]));
s0=t1;
b[0]=t1;
ep=1.0+eps;
while ((ep>=eps)&&(m<=9))
{
t2=0.5*t1;
for (k=0;k<=n-1;k++)
{
yy=y[0]+(k+0.5)*hh;
t2=t2+0.5*hh*bjpqf(x,yy);
}
m=m+1;
h[m-1]=h[m-2]/2.0;
g=t2;
l=0;
for (j=2;j<=m;j++)
{
s=g-b[j-2];
if (l==0)
if (fabs(s)+1.0==1.0)
{
l=1;
}
else
{
g=(h[m-1]-h[j-2])/s;
}
}
b[m-1]=g;
if (l!=0)
{
b[m-1]=1.0e+35;
}
s=b[m-1];
for (j=m;j>=2;j--)
{
s=b[j-2]-h[j-2]/s;
}
ep=fabs(s-s0)/(1.0+fabs(s));
n=n+n;
t1=t2;
s0=s;
hh=0.5*hh;
}
return(s);
}
</P> |
|