EETimes

Embedded Systems October 2000 Vol13_11

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

Contents of this Issue

Navigation

Page 19 of 181

PROGRAMMER'S TOOLBOX • Functions for Rarabolic fit II estimate a minimum via paraboLic fit doubLe para_fit(doubLe xO, doubLe x1, doubLe x2, doubLe yO, doubLe y1, doubLe y2){ doubLe mO = (y1 - yO)/(x1 - xO); doubLe m1 = (y2 - y1)/(x2 - x1); doubLe c = (m1 - mO)/(x2 - xO); return (xO + x1 - mO/c)/2.0; } II shrink an intervaL using paraboLic fit void para_shrink(doubLe &xO, doubLe &x1, doubLe &x2, doubLe &yO, doubLe &y1, doubLe &y2){ doubLe x = para_fit(xO, x1, x2, yO, y1, y2); doubLe y = f(x); if(x > x1){ swap(xO, x2); swap(yO, y2); } if«y > y1) && (x2 > xO»{ xO = x; yO = y; } eLse{ x2 = x1; y2 = y1; x1 = x; y1 = y; } swap(xO, x2); swap(yO, y2); } FIGURE 1 Alternating methods 0.1 0.01 0.001 0.0001 0.0001 000001 000001 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Iteration 18 OCTOBER 2000 Embedded Systems Programming I S,' J' " .. '},r, u -au . :: - ~- - x2

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems October 2000 Vol13_11