Embedded Systems September 2000 Vol13_10

Issue link:

Contents of this Issue


Page 21 of 229

PROGRAMMER'S TOOLBOX e It doesn't take long to discover that if you take care of the people too well, they multiply like rabbits. The people plow under your croplands and build houses and stores on them. Next thing you know, everyone's starving, the cof· fers are empty, your army is in rebellion, and you're lucky to escape alive. that it's never stressed . Tha t approach is what passes for good engineering in consumer circles. In fact, l contend that some prod- LISTING 1 double precision function fmin(ax,bx,f,tol) double precision ax,bx,tol external f double precision f integer iter c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c Listing continued ~ p. 24 an approximation x to the point where f attains a miniiTUil on the interval (ax,bx) is determined. input .. ax bx f Left endpoint of initial interval right endpoint of initial interval function subprogram which evaluates f(x) for any x in the interval (ax,bx) tol result ( .ge.O.) output .. fmin abcissa approximating the point where f attains a miniiTUil the method used is a combination of golden section search and successive parabolic interpolation. convergence is never much slower than that for a fibonacci search. if f has a continuous second derivative which is positive at the miniiTUil (which is not at ax or bx), then convergence is superlinear, and usually of the order of about 1.324 .... the function f is never evaluated at two points closer together than eps*abs(fmin)+(tol/3), where eps is approximately the square root of the relative machine precision. function and the computed values of if f f are always unimodal when separated by at Least eps*abs(x)+(tol/3), then fmin approximates the abcissa of the global miniiTUil of f on the interval ax,bx with an error Less than 3*eps*abs(fmin)+tol. if f then fmin may approximate a Local, but perhaps non-global, miniiTUil to the same accuracy. this function subprogram i.s a slightly modified version of the algol 60 procedure Localmin given in richard brent, algorithms for minimization without derivatives, prentice-hall, inc. (1973). is not unimodal, desired Length of the interval of uncertainty of the final ucts were never intended to work. I'm talking about the fairly cheap ones tha t come in blister packs, and look very much like the products you used when you were younger. The manu- facturer coun ts on your buying it ba eel on pleasan l memori es. It's not unLil you get it home and unwrap it that you d iscover it's a fake; it doesn ' t ac tually do anythin g. Th e vendo r counts on your not deeming it worth the effort to return the junk. My favorite example is one of those cir- cle-drawin g compasses like we all used in grade school. The new ones look just like the old ones, but they won ' t ho ld a se tting. Wha t? Yo u expected to actually draw a circle? You expected the staple r to actually dri ve staples? Silly you. Nevertheless, un til recently, manu- facturers at least made some pretense of trying to keep th eir custome rs happy. If your product didn 't work right, th ey'd u-y to make it good . They'd replace it, fix it for you, some- times even of fe r you extra perks to keep you happy. Now we move on L o the concept of acceptable loss. Years ago, in the early clays of pe rsonal computing, I got a game fo•- my TRS-80 call ed Hammurabi , the ancestor of all the Si m City sorts of games. In is a unimodal Hammurabi , you' re the king of Babylon, and it's your j ob to run the country so that it prospers, along with you. I reckon everyone who's ever played the game starts out resolving to be the world 's most benevolent king. No starvation, no lack for th e citizens of my coun try. I'm going to be remem- bered for keeping th e populace safe, happy, and well feel . It doe n ' t take long, playing such a game, to discove r that if you take care of th e peopl e too well , they multiply like rabbits. Immigra nts move in from outside to take advan- tage of yo ur la rgesse. The people 20 SEPTEMBER 2000 Embedded Systems Programming

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems September 2000 Vol13_10