Develop an M-file that is expressly designed to locate a maximum with the golden-section search algorithm. In other words, set it up so that it directly finds the maximum rather than finding the minimum of -f(x). Test your program with the same problem as Example 13.1. The function should have the following features:
• Iterate until the relative error falls below a stopping criterion or exceeds a maximum number of iterations.
• Return both the optimal x and f(x)? |
New search. (Also 1294 free access solutions) |