欢迎来到天天文库
浏览记录
ID:53594318
大小:26.00 KB
页数:5页
时间:2020-04-04
《机械优化设计c语言程序_2.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、计算f(x1,x2)=x0^2+x1^2-x0*x1-10*x0-4*x1+60#include"stdio.h"#include"stdlib.h"#include"math.h"doubleobjf(doublex[]){doubleff;ff=x[0]*x[0]+x[1]*x[1]-x[0]*x[1]-10*x[0]-4*x[1]+60;return(ff);}voidjtf(doublex0[],doubleh0,doubles[],intn,doublea[],doubleb[]){inti;double*x[3],h,f1,f2,f3;for(i=0;i<3;i
2、++)x[i]=(double*)malloc(n*sizeof(double));h=h0;for(i=0;i=f1){h=-h0;for(i=0;i3、2*h;for(i=0;i4、ublegold(doublea[],doubleb[],doubleeps,intn,doublexx[]){inti;doublef1,f2,*x[2],ff,q,w;for(i=0;i<2;i++)x[i]=(double*)malloc(n*sizeof(double));for(i=0;if2){for(i=0;i5、x[0]+i);*(x[0]+i)=*(x[1]+i);}f1=f2;for(i=0;i6、e(w>eps);for(i=0;i7、sg,n,x);free(a);free(b);return(ff);}doublepowell(doublep[],doubleh0,doubleeps,doubleepsg,intn,doublex[]){inti,j,m;double*xx[4],*ss,*s;doublef,f0,f1,f2,f3,fx,dlt,df,sdx,q,d;ss=(double*)malloc(n*(n+1)*sizeof(double));s=(double*)malloc(n*sizeof(double));for(i=0;i
3、2*h;for(i=0;i4、ublegold(doublea[],doubleb[],doubleeps,intn,doublexx[]){inti;doublef1,f2,*x[2],ff,q,w;for(i=0;i<2;i++)x[i]=(double*)malloc(n*sizeof(double));for(i=0;if2){for(i=0;i5、x[0]+i);*(x[0]+i)=*(x[1]+i);}f1=f2;for(i=0;i6、e(w>eps);for(i=0;i7、sg,n,x);free(a);free(b);return(ff);}doublepowell(doublep[],doubleh0,doubleeps,doubleepsg,intn,doublex[]){inti,j,m;double*xx[4],*ss,*s;doublef,f0,f1,f2,f3,fx,dlt,df,sdx,q,d;ss=(double*)malloc(n*(n+1)*sizeof(double));s=(double*)malloc(n*sizeof(double));for(i=0;i
4、ublegold(doublea[],doubleb[],doubleeps,intn,doublexx[]){inti;doublef1,f2,*x[2],ff,q,w;for(i=0;i<2;i++)x[i]=(double*)malloc(n*sizeof(double));for(i=0;if2){for(i=0;i5、x[0]+i);*(x[0]+i)=*(x[1]+i);}f1=f2;for(i=0;i6、e(w>eps);for(i=0;i7、sg,n,x);free(a);free(b);return(ff);}doublepowell(doublep[],doubleh0,doubleeps,doubleepsg,intn,doublex[]){inti,j,m;double*xx[4],*ss,*s;doublef,f0,f1,f2,f3,fx,dlt,df,sdx,q,d;ss=(double*)malloc(n*(n+1)*sizeof(double));s=(double*)malloc(n*sizeof(double));for(i=0;i
5、x[0]+i);*(x[0]+i)=*(x[1]+i);}f1=f2;for(i=0;i6、e(w>eps);for(i=0;i7、sg,n,x);free(a);free(b);return(ff);}doublepowell(doublep[],doubleh0,doubleeps,doubleepsg,intn,doublex[]){inti,j,m;double*xx[4],*ss,*s;doublef,f0,f1,f2,f3,fx,dlt,df,sdx,q,d;ss=(double*)malloc(n*(n+1)*sizeof(double));s=(double*)malloc(n*sizeof(double));for(i=0;i
6、e(w>eps);for(i=0;i7、sg,n,x);free(a);free(b);return(ff);}doublepowell(doublep[],doubleh0,doubleeps,doubleepsg,intn,doublex[]){inti,j,m;double*xx[4],*ss,*s;doublef,f0,f1,f2,f3,fx,dlt,df,sdx,q,d;ss=(double*)malloc(n*(n+1)*sizeof(double));s=(double*)malloc(n*sizeof(double));for(i=0;i
7、sg,n,x);free(a);free(b);return(ff);}doublepowell(doublep[],doubleh0,doubleeps,doubleepsg,intn,doublex[]){inti,j,m;double*xx[4],*ss,*s;doublef,f0,f1,f2,f3,fx,dlt,df,sdx,q,d;ss=(double*)malloc(n*(n+1)*sizeof(double));s=(double*)malloc(n*sizeof(double));for(i=0;i
此文档下载收益归作者所有