def dmp_discriminant(f, u, K):
 if (not u):
  return dup_discriminant(f, K)
 (d, v) = (dmp_degree(f, u), (u - 1))
 if (d <= 0):
  return dmp_zero(v)
 else:
  s = ((-1) ** ((d * (d - 1)) // 2))
  c = dmp_LC(f, K)
  r = dmp_resultant(f, dmp_diff(f, 1, u, K), u, K)
  c = dmp_mul_ground(c, K(s), v, K)
  return dmp_quo(r, c, v, K)

def dmp_discriminant ( f , u , K ) : if ( not u ) : return dup_discriminant ( f , K ) ( d , v ) = ( dmp_degree ( f , u ) , ( u - 1 ) ) if ( d <= 0 ) : return dmp_zero ( v ) else : s = ( ( - 1 ) ** ( ( d * ( d - 1 ) ) // 2 ) ) c = dmp_LC ( f , K ) r = dmp_resultant ( f , dmp_diff ( f , 1 , u , K ) , u , K ) c = dmp_mul_ground ( c , K ( s ) , v , K ) return dmp_quo ( r , c , v , K )
computes discriminant of a polynomial in k[x] .