def minimize_quadratic_1d(a, b, lb, ub, c=0):
 t = [lb, ub]
 if (a != 0):
  extremum = (((-0.5) * b) / a)
  if (lb < extremum < ub):
   t.append(extremum)
 t = np.asarray(t)
 y = (((a * (t ** 2)) + (b * t)) + c)
 min_index = np.argmin(y)
 return (t[min_index], y[min_index])

def minimize_quadratic_1d ( a , b , lb , ub , c = 0 ) : t = [ lb , ub ] if ( a != 0 ) : extremum = ( ( ( - 0.5 ) * b ) / a ) if ( lb < extremum < ub ) : t . append ( extremum ) t = np . asarray ( t ) y = ( ( ( a * ( t ** 2 ) ) + ( b * t ) ) + c ) min_index = np . argmin ( y ) return ( t [ min_index ] , y [ min_index ] )
minimize a 1-d quadratic function subject to bounds .