def dup_sign_variations(f, K):
 (prev, k) = (K.zero, 0)
 for coeff in f:
  if K.is_negative((coeff * prev)):
   k += 1
  if coeff:
   prev = coeff
 return k

def dup_sign_variations ( f , K ) : ( prev , k ) = ( K . zero , 0 ) for coeff in f : if K . is_negative ( ( coeff * prev ) ) : k += 1 if coeff : prev = coeff return k
compute the number of sign variations of f in k[x] .