This preview shows page 1. Sign up to view the full content.
Unformatted text preview: x2 = xU - p1 * (xU - xL); fx2 = f(x2); x for k = 1 : 1000 f Emax = (xU - xL) / 2; if display fprintf ('%5d %12.6f %12.6f %12.6f %12.6f %12.6f\n', . .. k, xL, x2, x1, xU, Emax); end if Emax <= Edes x = (xL + xU) / 2; return; end if fx2 < fx1 xU = x1; x1 = x2; fx1 = fx2; % old x2 becomes new x1 x2 = xU - p1 * (xU - xL); fx2 = f(x2); % brand new x2 required else xL = x2; x2 = x1; fx2 = fx1; % old x1 becomes new x2 x1 = xL + p1 * (xU - xL); fx1 = f(x1); % brand new x1 required end end e error ('Golden section search has not converged.'); e end...
View Full Document
This note was uploaded on 10/18/2010 for the course SYSC 3600 taught by Professor Adsd during the Spring '10 term at Universidad Alfonso X El Sabio.
- Spring '10