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) = a(1)f (a(1) =
2、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.500008 最优值为-0.25000