Issue link: http://dc.ee.ubm-us.com/i/71850

PROGRAMMER'S TOOLBOX • The loosest requirement on the function to be minimized is that it be continu- ous. If it is not-if its value jumps around between values of x that are arbi- trarily close-all bets are off, and we have nothing left to work with but random probi~gs. The functions fix) and g(x), howev- er, also have continous first derivatives (in fact, all their derivatives are con- tinuous) . Thal is why their shape in the vicinily of the minimum must look like a parabola. It should go without saying thal an On occasion, I've also used a variation: (17) TABLE 1 irhe test functions ' (1) (2) (3) (4) (5) (6) (7) f (x) = COS(21rX 3) g(x ) = sin(21rx 3) h(x) = ~17TX - 11- 1 a(x) = Ix - 0.7771 L(x) = x R(x) =-x K(x) = 1 I use this variation because g(x) has a maximum before its minimum. As we will see in a moment, il'S important thal our algorithm work even when the function increases for a time before decreasing-that's why g(x) has value for us. h should go without saying that one or two functions are not enough lO prove lhe algorithm. As I gel ever closer to the completed algorithm, I want to be quite sure that it works for functions that mighl seem, in some way, to be "pathological." The loosest requirement o n the function to be minimized is that it be continuous. If it is not- if its value jumps around between values of x that are arbitrarily close-all bet are off, and we have nothing left to work with but random probings. If we are to have any hope o[ searching for a solution in the usual sense of lhe term, we must require that the func- tion be conlinuous, algorithm that assumes a function shaped like a parabola works very well when the [unction is a parabola. In facl, such a method should converge right away, and if it doesn't, we need to fall back and regroup. On the other hand, many functions in nature don 't have con tinuous first derivatives, and therefore don't look like parabola, no matter what power of zoom lens we apply. An obvious example is: j(X) = H (18) Any decent general-purpose algo- rithm should find the minimum al x = O. Not surprisingly, Brent's method, being based o n successive quadratic fits , works well when the function looks like a parabola, and pretty badly with a function such as the one given in Equation 18, It ends up falling back on successive bisections, not the para- bolic fit. For the remainder of this series, LlSnNG 1 II Local minimizer; exits at encounter of first minimum double minimize(double (*f)(double), double xO, double x1, long n){ static double xmin = xO; static double ymin = f(xO); double dx = (x1 - xO)/n; double y; xO += dx; y = f(xO); while«xO < x1) && (y <= ymi n»{ ymin = y; xmin = xO; xO += dx; y = f(xO); } return xmi n; } I'm adopting an even more stringent function: h(x) = ~17TX - 11 - I (19) The square root function causes the shape to be the opposite ofa parabola, in a sense, The closer one gets to the minimum, the steeper the slope of the function, and the more a sharp edge forms at the minimum. Does thi mean that we don't need the simple absolute value? Not at all. This function is unique in that it has segments that are traight lines on either side of the minimum. A mart minimizer should recognize this fact, and exploil it. Brent's method doe 'n 't. Fortunately, we are in position to achieve fast convergence for this case, 28 DECEMBER 2000 Embedded Systems Programming

- December001
- December002
- December003
- December004
- December005
- December006
- December007
- December008
- December009
- December010
- December011
- December012
- December013
- December014
- December015
- December016
- December017
- December018
- December019
- December020
- December021
- December022
- December023
- December024
- December025
- December026
- December027
- December028
- December029
- December030
- December031
- December032
- December033
- December034
- December035
- December036
- December037
- December038
- December039
- December040
- December041
- December042
- December043
- December044
- December045
- December046
- December047
- December048
- December049
- December050
- December051
- December052
- December053
- December054
- December055
- December056
- December057
- December058
- December059
- December060
- December061
- December062
- December063
- December064
- December065
- December066
- December067
- December068
- December069
- December070
- December071
- December072
- December073
- December074
- December075
- December076
- December077
- December078
- December079
- December080
- December081
- December082
- December083
- December084
- December085
- December086
- December087
- December088
- December089
- December090
- December091
- December092
- December093
- December094
- December095
- December096
- December097
- December098
- December099
- December100
- December101
- December102
- December103
- December104
- December105
- December106
- December107
- December108
- December109
- December110
- December111
- December112
- December113
- December114
- December115
- December116
- December117
- December118
- December119
- December120
- December121
- December122
- December123
- December124
- December125
- December126
- December127
- December128
- December129
- December130
- December131
- December132
- December133
- December134
- December135
- December136
- December137
- December138
- December139
- December140
- December141
- December142
- December143
- December144
- December145
- December146
- December147
- December148
- December149
- December150
- December151
- December152
- December153
- December154
- December155
- December156
- December157
- December158
- December159
- December160
- December161
- December162
- December163
- December164
- December165
- December166
- December167
- December168
- December169
- December170
- December171
- December172
- December173
- December174
- December175
- December176
- December177
- December178
- December179
- December180
- December181
- December182
- December183
- December184
- December185
- December186
- December187
- December188
- December189
- December190
- December191
- December192
- December193
- December194
- December195
- December196
- December197
- December198