EETimes

Embedded Systems September 2000 Vol13_10

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

Contents of this Issue

Navigation

Page 48 of 229

PROGRAMMER'S TOOLBOX On to parabolas Now that we remembe r how to do the golden section search, let's see what we can do with parabolic fits. In my column "A Simulator's Paradise," (Apri l 2000, p. 11 ), I worked o ut the formulas for fitting a parabola through three points, and estima ting the minimum. The ma th goes: Xmin =2 x, +x2 -~ I ( where: c = m,- mo x 2 -x1 and rn0 and m1 are the two slopes: 0.4 -- JJ.· m2 = Y1- Yo x 1 -x0 m, = Y2 - Y1 x 2 -x1 (4) (5) ot again that the algorithm doesn 't real ly care whether the .xs increase to the left 01· the right, so anything we do in terms of swapping ends will not affect tJ1e r ult. Using Equations 2 through 5, we can write a function that estimates the min- imum by means of parabolic fit. This is shown as para_fit( ) in Listing 3. Looking at this code, I think, "Gee, it sure doesn't bear much resemblance to Brent's p, q, r, x, w, v, d, and e, does it?" Never mind. I'm sure the two par- abolic fits are equivalent-it's pretty hard to get that part wrong-but I'm not currently incl ined to prove the equivalence. I understand what I've got, and that's enough for me. Once we have an estimated X,11 ;n from the parabolic fit, we sti ll have to decide what to do with it. Clearly, if it's outside the interval Xo·· X2· it's no good and we must discard it. However, tl1is should never happen. Our fundamen- 0 .001 )( e 0.0001 0.0001 0 .0000001 ~ 0.000001 ! 1 ! I -o- xo ( ---a--- x, J I · - -.Q.-- X2 I; 3 4 5 6 ' FIGURE J 0 .2 - ··=:o- ~~--1 ....:.- 3 4 5 6 7 8 9 10 11 Iteration m o) (2) I'm sure the two parabolic fits are equivalent-it's pretty hard to get that part wrong-but I'm not currently inclined to prove the equivalence. I understand what I've got, and that's enough for me. tal assumption is that: Yo> y , < Y2 (6) We assume that th is is true going into the algorithm, and we take steps to (3) e )( 0.6 i ! -- ·ll·-- x, ! - ! i o ~~---·-~---,-- - -- ------=-=====::;:;;:;;;;:::::;:::::==-==-:::.:':=:.·::::D 2 12 " i - x2 J i! ji . ' - \ . '.: ·a-_:_- a. : " , ' ,, - ~ ., : \ ' ' I ' :--- .. , -~ ~ ' ~- .. ~-' - -. ~- - .; .... \ ,- ' : .. '\ : \ !\\ '· · ' ' ,~a.. .:.. .c. ,: ·-c< -- ,. -., 7 8 9 10 Iteration ' A ~ :_"l:Jr ..,.. -.1)- ,- ooll - '- 11 12 .. "1 . - ~ I !I -! I· "'l l ll !1 ~ ---,-..,:--· ·:··:_ .. :- ·:····-··=· ='==='==::;:;;:;:::;:;;;;:;;:::::=== ................ ~ 2 ll li i· Embedded Systems Programming SEPTEMBER 2000 47

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems September 2000 Vol13_10