#include "math.h"
#include "stdio.h"
#define c 0
#define d 3.14
#define MAX_N 1000
#define h 0.25*0.3
#define k (2*3.14)/0.3
#define q0 1.2*3.14/2 /*此处改变θ值*/
#define c1shi 9.41
#define c1xu -3.58
#define c2shi 0.44
#define c2xu -2.03
#define Y 0.25
#define v 0.8 /*v=Y/X*/
int m,n;
double maxf(double e)
{double t,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12;
t1=k*h*(cos(e));
t2=cos(k*h);
t3=cos(t1);
t11=(t3-t2)/(sin(e));
t4=cos(2*k*h);
t5=(sin(e))*(sin(e))+3;
t6=(t3-t4)/t5;
t7=t6*(sin(e));
t12=2*t7;
t8=c1shi*t11+c2shi*t12;
t9=c1xu*t11+c2xu*t12;
t10=t8*t8+t9*t9;
t=sqrt(t10);
printf("\n");
printf("q0=%e\n",e);
printf("C1=%e - j%e\n",c1shi,-c1xu);
printf("C2=%e - j%e\n",c2shi,-c2xu);
printf("f=");
printf("%e - j%e\n",t8,-t9);
printf("f(max)=%e\n",t);
return(t);
}
double f(double x,double y)
{double p,g;
double a[8],q[8];
double t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13;
q[m]=(2*3.14/8)*m;
q[n]=(2*3.14/8)*n;
t1=(1-v*v)*cos(q[m])*cos(q[m]);
t2=sqrt(1-t1);
a[m]=Y/t2;
t3=(1-v*v)*cos(q[n])*cos(q[n]);
t4=sqrt(1-t3);
a[n]=Y/t4;
t5=a[m]*sin(q[m])-a[n]*sin(q[n]);
t6=a[m]*cos(q[m])-a[n]*sin(q[n]);
g=atan2(t5,t6);
if(m!=n)
{t7=a[m]*a[m]+a[n]*a[n]-2*a[m]*a[n]*cos(q[m]-q[n]);
p=sqrt(t7);
}
else
p=0;
t8=cos(y-g);
t9=k*p*sin(x)*t8;
t10=cos(t9)*sin(x);
t11=maxf(q0)*maxf(q0);
t12=t10*t11;
t13=t11*sin(x);
if(m!=n)
return t12;
else
return t13;
}
double chongjifen()
{int r,t;
int i,j;
double a,b;
double s,HX,x,y,Q,L,J;
double J1,J2,J3,K1,K2,K3;
r=20,t=20;
a=0,b=2*3.14;
s=(b-a)/t;
J1=0;
J2=0;
J3=0;
for(i=0;i<=t;i++)
{x=a+i*s;
HX=(d-c)/r;
K1=f(x,c)+f(x,d);
K2=0;
K3=0;
for(j=1;j<r;j++)
{y=c+j*HX;
Q=f(x,y);
if(j%2==0)
K2=K2+Q;
else
K3=K2+Q;
}
L=(K1+2*K2+4*K3)*HX/3;
if(i==0||i==t)
J1=J1+L;
else
if(i%2==0)
J2=J2+L;
else
J3=J3+L;
}
J=(J1+2*J2+4*J3)*s/3;
printf("J=%lf\n",J);
return J;
}
main()
{double z[8][8];
int i,j;
for(m=0;m++;m<8)
for(n=0;n++;n<8)
z[m][n]=chongjifen();
for(i=0;i<=2;i++)
{for(j=0;j<=2;j++)
printf(" %13.7e ",z[i][j]);
printf("\n");
}
}
我花了几天时间编了此程序,求二重积分,可是有两个警告,我不知怎么改,还请高手赐教!
感激不尽!