|
<P>不是高手,斗胆一试,建议搂主以后提问用务实一点的方法,呵呵,把想帮忙的同志都吓跑了<BR>#include<STDIO.H><BR>#include<CONIO.H><BR>#include<MATH.H><BR>void main()<BR>{<BR> int i=1,n=50;<BR> double xm;<BR> double t=0.0;<BR> double f(double x,double t);<BR> double Simpson(double(*f)(double,double),double,double,int);<BR> for(t=0.0;t<=2.0;i++)<BR> {<BR> n = 50;<BR> xm=Simpson(f,0.0,t,n);<BR> printf("%d\n",i);<BR> printf("x(%f)=%lf\n",t,xm);<BR> xm=0.0;<BR> t=t+double(0.025);<BR> n=n*(i+1);<BR> }<BR>}<BR>double Simpson(double (*f)(double x,double t),double a,double b,int n)<BR>{<BR> int k;<BR> double s,s1,s2=0.0;<BR> double h=(b-a)/n;<BR> s1=f(a+h/2,b);<BR> for(k=1;k<=n-1;k++)<BR> {<BR> s1=s1+f(a+k*h,b);<BR> s2=s2+f(a+k*h,b);<BR> }<BR> s=h/6*(f(a,b)+4*s1+2*s2+f(b,b));<BR> return s;<BR>}</P>
<P><BR>double f(double x,double t)<BR>{ <BR> double temp;<BR> temp = sin(10*x)*exp(1.25*(x-t));<BR> temp = temp*sin(24.968730*(t-x))*(25000/24968.730444);<BR> return temp;<BR>}<BR>现在都能算过去了,结果自己找别的数学软件比较吧。</P> |
|