Develop an M-file to implement parabolic interpolation to locate a minimum. The function should have the following features:
• Base it on two initial guesses, and have the program generate the third initial value at the midpoint of the interval.
• Check whether the guesses bracket a maximum. If not, the function should not implement the algorithm, but should return an error message.
• 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).
Test your program with the same problem as Example 7.3.
Example 7.3:
Parabolic Interpolation
Problem Statement. Use parabolic interpolation to approximate the minimum of
with initial guesses of x1 = 0, x2 = 1, and x3 = 4.
Solution. The function values at the three guesses can be evaluated:
and substituted into Eq. (7.10) to give
which has a function value of f(1.5055) = −1.7691.
Next, a strategy similar to the golden-section search can be employed to determine which point should be discarded. Because the function value for the new point is lower than for the intermediate point (x2) and the new x value is to the right of the intermediate point, the lower guess (x1) is discarded. Therefore, for the next iteration:
which can be substituted into Eq. (7.10) to give
which has a function value of f(1.4903) = −1.7714. The process can be repeated, with the results tabulated here:
Thus, within five iterations, the result is converging rapidly on the true value of −1.7757 at x = 1.4276.
Equation (7.10):
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.