0% found this document useful (0 votes)
39 views2 pages

Golden Section Via Excel

This document describes an algorithm to find the maximum value of a unimodal function f(x) on an interval [a,b] within a specified tolerance t. The algorithm uses the golden ratio to select test points x1 and x2 within the interval. It compares the function values at these points and shrinks the interval accordingly until the length of the interval is less than the tolerance t. It then estimates the maximum as the midpoint of the final interval.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

Golden Section Via Excel

This document describes an algorithm to find the maximum value of a unimodal function f(x) on an interval [a,b] within a specified tolerance t. The algorithm uses the golden ratio to select test points x1 and x2 within the interval. It compares the function values at these points and shrinks the interval accordingly until the length of the interval is less than the tolerance t. It then estimates the maximum as the midpoint of the final interval.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 2

To find a maximum solution to given a function, f(x), on the interval [a, b] where the function, f(x), is unimodal.

INPUT: endpoints a, b; tolerance, t


OUTPUT:final interval [ai, bi], f(midpoint)
Step 1.
Step 2.

Initialize the tolerance, t >0.


Set r=0.618 and define the test points
x1 = a + (1-r)(b-a)
x2 = a + r(b-a)

Step 3.

Calculate f(x1) and f(x2)


Compare f(x1) and f(x2)

Step 4.

a. If f(x1) < f(x2), then the new interval is [x1, b]:


a becomes the previous x1
b does not change
x1 becomes the previous x2
Find the new x2 using the formula in Step 2.
b. If f(x1) > f(x2), then the new interval is [a, x2]:
a does not change
b becomes the previous x2
x2 becomes the previous x1
Find the new x1 using the formula in Step 2.
Step 5.
Step 6.

If the length of the new interval from Step 4 is less than the tolerance
specified, the stop. Otherwise go back to Step 3.
Estimate x* as the midpoint of the final interval and compute, f(x*), the
estimated maximum of the function.

STOP

Max -x^2-1 over -1 to 0.75, tolerance =.25


r
Number of experimental iterations

0.61803399
4.04330833

x2

f(x1)

x1

-1

0.75

-0.3315594803

0.08155948 -1.10993169 -1.00665195

f(x2)

-0.33155948

0.75

0.0815594803

0.33688104 -1.00665195 -1.11348883

-0.33155948 0.33688104

-0.0762379212

0.08155948 -1.00581222 -1.00665195

-0.33155948 0.08155948

-0.1737620788

-0.07623792 -1.03019326 -1.00581222

-0.17376208 0.08155948

-0.0762379212

-0.01596468 -1.00581222 -1.00025487

-0.07623792 0.08155948

STOP

|B-A|
1.75
1.08155948
0.66844052
0.41311896
0.25532156
0.1577974

You might also like