def dup_discriminant(f, K):
 d = dup_degree(f)
 if (d <= 0):
  return K.zero
 else:
  s = ((-1) ** ((d * (d - 1)) // 2))
  c = dup_LC(f, K)
  r = dup_resultant(f, dup_diff(f, 1, K), K)
  return K.quo(r, (c * K(s)))

def dup_discriminant ( f , K ) : d = dup_degree ( f ) if ( d <= 0 ) : return K . zero else : s = ( ( - 1 ) ** ( ( d * ( d - 1 ) ) // 2 ) ) c = dup_LC ( f , K ) r = dup_resultant ( f , dup_diff ( f , 1 , K ) , K ) return K . quo ( r , ( c * K ( s ) ) )
computes discriminant of a polynomial in k[x] .