def bezier_real_minmax(p):
local_extremizers = [<NUM_LIT:0>, <NUM_LIT:1>]<EOL>if len(p) == <NUM_LIT:4>:  <EOL><INDENT>a = [p.real for p in p]<EOL>denom = a[<NUM_LIT:0>] - <NUM_LIT:3>*a[<NUM_LIT:1>] + <NUM_LIT:3>*a[<NUM_LIT:2>] - a[<NUM_LIT:3>]<EOL>if denom != <NUM_LIT:0>:<EOL><INDENT>delta = a[<NUM_LIT:1>]**<NUM_LIT:2> - (a[<NUM_LIT:0>] + a[<NUM_LIT:1>])*a[<NUM_LIT:2>] + a[<NUM_LIT:2>]**<NUM_LIT:2> + (a[<NUM_LIT:0>] - a[<NUM_LIT:1>])*a[<NUM_LIT:3>]<EOL>if delta >= <NUM_LIT:0>:  <EOL><INDENT>sqdelta = sqrt(delta)<EOL>tau = a[<NUM_LIT:0>] - <NUM_LIT:2>*a[<NUM_LIT:1>] + a[<NUM_LIT:2>]<EOL>r1 = (tau + sqdelta)/denom<EOL>r2 = (tau - sqdelta)/denom<EOL>if <NUM_LIT:0> < r1 < <NUM_LIT:1>:<EOL><INDENT>local_extremizers.append(r1)<EOL><DEDENT>if <NUM_LIT:0> < r2 < <NUM_LIT:1>:<EOL><INDENT>local_extremizers.append(r2)<EOL><DEDENT><DEDENT>local_extrema = [bezier_point(a, t) for t in local_extremizers]<EOL>return min(local_extrema), max(local_extrema)<EOL><DEDENT><DEDENT>dcoeffs = bezier2polynomial(a, return_poly1d=True).deriv().coeffs<EOL>local_extremizers += polyroots01(dcoeffs)<EOL>local_extrema = [bezier_point(a, t) for t in local_extremizers]<EOL>return min(local_extrema), max(local_extrema)<EOL>
returns the minimum and maximum for any real cubic bezier