Develop an M-file to locate a minimum with the golden-section search. Rather than using the maximum iterations and Eq. (7.9) as the stopping criteria, determine the number of iterations needed to attain a desired tolerance. Test your function by solving Example 7.2 using Ea,d= 0.0001.
Equation (7.9):
Example 7.2:
Golden-Section Search
Problem Statement. Use the golden-section search to find the minimum of
within the interval from xl = 0 to xu = 4.
Solution. First, the golden ratio is used to create the two interior points:
The function can be evaluated at the interior points:
Because f (x2) < f (x1), our best estimate of the minimum at this point is that it is located at x = 1.5279 with a value of f (x) = –1.7647. In addition, we also know that the minimum is in the interval defined by xl, x2, and x1. Thus, for the next iteration, the lower bound remains xl = 0, and x1 becomes the upper bound, that is, xu = 2.4721. In addition, the former x2 value becomes the new x1, that is, x1 = 1.5279. In addition, we do not have to recalculate f (x1), it was determined on the previous iteration as f (1.5279) = –1.7647.
All that remains is to use Eqs. (7.8) and (7.7) to compute the new value of d and x2:
The function evaluation at x2 is f (0.9943) = −1.5310. Since this value is less than the function value at x1, the minimum is f (1.5279) = −1.7647, and it is in the interval prescribed by x2, x1, and xu. The process can be repeated, with the results tabulated here:
Note that the current minimum is highlighted for every iteration. After the eighth iteration, the minimum occurs at x = 1.4427 with a function value of −1.7755. Thus, the result is converging on the true value of −1.7757 at x = 1.4276.
Equation (7.8):
Equation (7.7):
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.