def process_bezout_output(poly_seq, x):
 L = poly_seq[:]
 d = degree(L[1], x)
 i = 2
 while (i < len(L)):
  d_i = degree(L[i], x)
  if (d_i < 0):
   L.remove(L[i])
   i = (i - 1)
  if (d == d_i):
   L.remove(L[i])
   i = (i - 1)
  if (d_i >= 0):
   d = d_i
  i = (i + 1)
 return L

def process_bezout_output ( poly_seq , x ) : L = poly_seq [ : ] d = degree ( L [ 1 ] , x ) i = 2 while ( i < len ( L ) ) : d_i = degree ( L [ i ] , x ) if ( d_i < 0 ) : L . remove ( L [ i ] ) i = ( i - 1 ) if ( d == d_i ) : L . remove ( L [ i ] ) i = ( i - 1 ) if ( d_i >= 0 ) : d = d_i i = ( i + 1 ) return L
poly_seq is a polynomial remainder sequence computed either by subresultants_bezout or by modified_subresultants_bezout .