《机械优化设计大作业(共4页).doc》由会员分享,可在线阅读,更多相关《机械优化设计大作业(共4页).doc(4页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上 机械优化设计大作业1.求f =(x-4)*(x-5)的最优解和最优值已知初始搜索区间为0,10,迭代精度e=0.001.2.用黄金分割法3.黄金分割法的算法框图给定:a,b,eb-0.618(b-a) =a (1) ;f(a (1) ) = f1a+0.618(b-a) = a (2) ;f(a (2) ) = f2a(2) = b,a(1) = a(2)f1 = f2a+0.618(b-a)= a(1)f (a(2) =f2输出:0.5(b+a) = a* ;f*=f(a*)停+-+f 1a,a(2) = a (1) ,f2 = f1b-0.618(b-a) =
2、a(1)f (a(1) =f1b-a=e?4.程序#include#includedouble f(double x) return(x-4)*(x-5);void main(void) double a1,y1,a2,y2,a,b,k,e; a=0;b=10;e=0.001;k=0.618; a1=b-k*(b-a);y1=f(a1); a2=a+k*(b-a);y2=f(a2); printf(ata1tta2tbtty2n); while(fabs(b-a)e) if(y1=y2) a=a1;a1=a2;y1=y2; a2=a+k*(b-a);y2=f(a2); elseb=a2;a2=a1;y2=y1; a1=b-k*(b-a);y1=f(a1); printf(%f %f %f %f %fn,a,a1,a2,b,y1,y2); printf(x*=%fn,(a+a2)/2); printf(y*=%fn,y1);5.经c+运行的结果为经运算最终结果为; 最优解为4. 最优值为-0.25000专心-专注-专业