# Ticket #13672: 13672_pari_resultant.patch

File 13672_pari_resultant.patch, 2.7 KB (added by jdemeyer, 9 years ago)
• ## sage/rings/polynomial/polynomial_element.pyx

```# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1358698473 -3600
# Node ID 6c96b0f8eafe6f3871e152af00594d087073d665
# Parent  5ed6c99a1538eac8cafc6a5f071e047d54725698
Fix PARI call in resultant()

diff --git a/sage/rings/polynomial/polynomial_element.pyx b/sage/rings/polynomial/polynomial_element.pyx```
 a sage: h.parent() is R True """ variable = self.parent().gen() if str(variable)<>'x' and self.parent()._mpoly_base_ring()<>self.parent().base_ring(): bigring = sage.rings.polynomial.multi_polynomial.PolynomialRing(self.parent()._mpoly_base_ring(),list(self.parent().variable_names_recursive())) newself = bigring(self) newother = bigring(other) return self.parent().base_ring()(newself.resultant(newother,bigring(variable))) # The 0 flag tells PARI to use exact arithmetic res = self._pari_().polresultant(other._pari_(), variable._pari_(), 0) Check that :trac:`13672` is fixed:: sage: R. = GF(2)[] sage: S. = R[] sage: f = (t^2 + t)*x + t^2 + t sage: g = (t + 1)*x + t^2 sage: f.resultant(g) t^4 + t """ variable = self.variable_name() if variable != 'x' and self.parent()._mpoly_base_ring() != self.parent().base_ring(): bigring = sage.rings.polynomial.multi_polynomial.PolynomialRing(self.parent()._mpoly_base_ring(),list(self.parent().variable_names_recursive())) newself = bigring(self) newother = bigring(other) return self.parent().base_ring()(newself.resultant(newother,bigring(self.parent().gen()))) # Main variable is "x": we can use PARI to compute the resultant res = self._pari_with_name().polresultant(other._pari_with_name(), variable) return self.parent().base_ring()(res) def discriminant(self): sage: f = x^2 + a sage: f.discriminant() 1 The following examples show that #11782 has been fixed:: Check that :trac:`13672` is fixed:: sage: R. = GF(5)[] sage: S. = R[] sage: f = x^10 + 2*x^6 + 2*x^5 + x + 2 sage: (f-t).discriminant() 4*t^5 The following examples show that :trac:`11782` has been fixed:: sage: ZZ.quo(81)[x](3*x^2 + 3*x + 3).discriminant() 54 sage: ZZ.quo(9)[x](2*x^3 + x^2 + x).discriminant()