protected double interpolate ( double boundA , double boundB ) { double alphaNew ; // interpolate minimum for rapid convergence if ( Double . isNaN ( gp ) ) { alphaNew = SearchInterpolate . quadratic ( fprev , gprev , stprev , fp , stp ) ; } else { alphaNew = SearchInterpolate . cubic2 ( fprev , gprev , stprev , fp , gp , stp ) ; if ( Double . isNaN ( alphaNew ) ) alphaNew = SearchInterpolate . quadratic ( fprev , gprev , stprev , fp , stp ) ; } // order the bound double l , u ; if ( boundA < boundB ) { l = boundA ; u = boundB ; } else { l = boundB ; u = boundA ; } // enforce min/max allowed values if ( alphaNew < l ) alphaNew = l ; else if ( alphaNew > u ) alphaNew = u ; return alphaNew ; }
Use either quadratic of cubic interpolation to guess the minimum .