Page 153 -
P. 153

[xmin,ymin]=goldensection('cos',3,3.5,10^(-4))


                             5.3.3  MATLAB fmin and fmins Built-in Function

                             Following methodically the same steps using fzero to find the zeros of any
                             function, we can use the fmin command to find the minimum of a function
                             of one variable on a given interval. The recommended sequence of steps is as
                             follows:

                                1. Edit a function M-file for the function under consideration.
                                2. Plot the curve of the function over the desired domain, to overview
                                   the function shape and have an estimate of the position of the
                                   minimum.
                                3. Use the command fmin to accurately find the minimum. The syn-
                                   tax is as follows:

                                xmin=fmin('funname',a,b) % [a,b] is the interval

                              The local maximum of a function f(x) on an interval can be computed by
                             noting that this quantity can be deduced from knowing the values of the
                             coordinates of the local minimum of –f(x). The implementation of this task
                             consists of creating a file for the negative of this function (call it n-funname)
                             and entering the following commands in the command window:

                                xmax=fmin('n-funname',xi,xf)
                                fmax=-1*feval('n-funname',xmax)




                             Homework Problems
                             Pb. 5.22 We have two posts of height 6 m and 8 m, and separated by a dis-
                             tance of 21 m. A line is to run from the top of one post to the ground between
                             the posts and then to the top of the other post (Figure 5.3). Find the configu-
                             ration that minimizes the length of the line.
                             Pb. 5.23 Fermat’s principle states that light going from Point A to Point B
                             selects the path which requires the least amount of travel time. Consider the
                             situation in which an engineer in a submarine wants to communicate, using
                             a laser-like pointer, with a detector at the top of the mast of another boat. At
                             what angle θ to the vertical should he point his beam? Assume that the detec-
                             tor is 50 ft above the water surface, the submarine transmitter is 30 ft under
                             the surface, the horizontal distance separating the boat from the submarine is
                             100 ft, and the velocity of light in water is 3/4 of its velocity in air (Figure 5.4).




                             © 2001 by CRC Press LLC
   148   149   150   151   152   153   154   155   156   157   158