#NEWLINE# def minimize_quadratic_1d( a , b , lb , ub , c = 0 ) : #NEWLINE# #INDENT# 'Minimize a 1-d quadratic function subject to bounds.\n    \n    The free term `c` is 0 by default. Bounds must be finite.\n    \n    Returns\n    -------\n    t : float\n        Minimum point.\n    y : float\n        Minimum value.\n    ' #NEWLINE# t = [ lb , ub ] #NEWLINE# if ( a != 0 ) : #NEWLINE# #INDENT# extremum = ( ( ( - 0.5 ) * b ) / a ) #NEWLINE# if ( lb < extremum < ub ) : #NEWLINE# #INDENT# t . append ( extremum ) #NEWLINE# #UNINDENT# #UNINDENT# t = np . asarray ( t ) #NEWLINE# y = ( ( ( a * ( min_index ** 2 ) ) + ( b * t ) ) + c ) #NEWLINE# min_index = np . argmin ( y ) #NEWLINE# return ( t [ min_index ] , y [ min_index ] )