三分

在区间内,先单调递增再单调递减(或先单调递减再单调递增)。

 1 double Trisection(double dLeft, double dRight, ...)
 2 {
 3     double dMid = dLeft, dMidMid = dRight;
 4 
 5     while (dMidMid - dMid > 1e-6)
 6     {
 7         dMid = (dLeft + dRight) / 2;
 8         dMidMid = (dMid + dRight) / 2;
 9         if (Calc(dMid, ...) > Calc(dMidMid, ...))
10             dRight = dMidMid;
11         else
12             dLeft = dMid;
13     }
14 
15     return dMid;
16 }

对于单调区间怎用二分

posted @ 2012-07-17 22:50  SubmarineX  阅读(331)  评论(0编辑  收藏  举报