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 b  
    43324332            sage: h.parent() is R
    43334333            True
    43344334
    4335         """
    4336         variable = self.parent().gen()
    4337         if str(variable)<>'x' and self.parent()._mpoly_base_ring()<>self.parent().base_ring():
    4338           bigring = sage.rings.polynomial.multi_polynomial.PolynomialRing(self.parent()._mpoly_base_ring(),list(self.parent().variable_names_recursive()))
    4339           newself = bigring(self)
    4340           newother = bigring(other)
    4341           return self.parent().base_ring()(newself.resultant(newother,bigring(variable)))
    4342         # The 0 flag tells PARI to use exact arithmetic       
    4343         res = self._pari_().polresultant(other._pari_(), variable._pari_(), 0)
     4335        Check that :trac:`13672` is fixed::
     4336
     4337            sage: R.<t> = GF(2)[]
     4338            sage: S.<x> = R[]
     4339            sage: f = (t^2 + t)*x + t^2 + t
     4340            sage: g = (t + 1)*x + t^2
     4341            sage: f.resultant(g)
     4342            t^4 + t
     4343        """
     4344        variable = self.variable_name()
     4345        if variable != 'x' and self.parent()._mpoly_base_ring() != self.parent().base_ring():
     4346            bigring = sage.rings.polynomial.multi_polynomial.PolynomialRing(self.parent()._mpoly_base_ring(),list(self.parent().variable_names_recursive()))
     4347            newself = bigring(self)
     4348            newother = bigring(other)
     4349            return self.parent().base_ring()(newself.resultant(newother,bigring(self.parent().gen())))
     4350        # Main variable is "x": we can use PARI to compute the resultant
     4351        res = self._pari_with_name().polresultant(other._pari_with_name(), variable)
    43444352        return self.parent().base_ring()(res)
    43454353
    43464354    def discriminant(self):
     
    44214429            sage: f = x^2 + a
    44224430            sage: f.discriminant()
    44234431            1
    4424        
    4425         The following examples show that #11782 has been fixed::
    4426        
     4432
     4433        Check that :trac:`13672` is fixed::
     4434
     4435            sage: R.<t> = GF(5)[]
     4436            sage: S.<x> = R[]
     4437            sage: f = x^10 + 2*x^6 + 2*x^5 + x + 2
     4438            sage: (f-t).discriminant()
     4439            4*t^5
     4440
     4441        The following examples show that :trac:`11782` has been fixed::
     4442
    44274443            sage: ZZ.quo(81)[x](3*x^2 + 3*x + 3).discriminant()
    44284444            54
    44294445            sage: ZZ.quo(9)[x](2*x^3 + x^2 + x).discriminant()