浮点三分模板

/* 
浮点数三分模板 
*/  
const double EPS = 1e-10;    
    
double calc(double x)  {    
    double res;  
    return res;  
}    
    
double ternarySearch(double l, double r)  {    
    while(r-l>EPS){
        double m1=l+(r-l)/3;
        double m2=r-(r-l)/3;
        if(cal(m1)>cal(m2))
            r=m2;
        else
            l=m1;
    }  
    return l;
}  

点赞