diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py index a9bcc7d2940..c6edf75c3a5 100644 --- a/src/sage/calculus/calculus.py +++ b/src/sage/calculus/calculus.py @@ -889,7 +889,7 @@ def minpoly(ex, var='x', algorithm=None, bits=None, degree=None, epsilon=0): sage: f = a.minpoly(); f x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576 sage: f(a) - ((((sqrt(5) + sqrt(3) + sqrt(2))^2 - 40)*(sqrt(5) + sqrt(3) + sqrt(2))^2 + 352)*(sqrt(5) + sqrt(3) + sqrt(2))^2 - 960)*(sqrt(5) + sqrt(3) + sqrt(2))^2 + 576 + (sqrt(5) + sqrt(3) + sqrt(2))^8 - 40*(sqrt(5) + sqrt(3) + sqrt(2))^6 + 352*(sqrt(5) + sqrt(3) + sqrt(2))^4 - 960*(sqrt(5) + sqrt(3) + sqrt(2))^2 + 576 sage: f(a).expand() 0 @@ -906,7 +906,7 @@ def minpoly(ex, var='x', algorithm=None, bits=None, degree=None, epsilon=0): NotImplementedError: Could not prove minimal polynomial x^4 - 5/4*x^2 + 5/16 (epsilon 0.00000000000000e-1) sage: f = a.minpoly(algorithm='numerical', epsilon=1e-100); f x^4 - 5/4*x^2 + 5/16 - sage: f(a).numerical_approx(100) + sage: f(a).horner(a).numerical_approx(100) 0.00000000000000000000000000000 The degree must be high enough (default tops out at 24). diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py index 2939b99d3d1..a8fe315a88d 100644 --- a/src/sage/functions/orthogonal_polys.py +++ b/src/sage/functions/orthogonal_polys.py @@ -1225,7 +1225,7 @@ def gen_legendre_P(n,m,x): sage: gen_legendre_P(3, 1, t) -3/2*(5*t^2 - 1)*sqrt(-t^2 + 1) sage: gen_legendre_P(4, 3, t) - 105*(t^2 - 1)*sqrt(-t^2 + 1)*t + 105*(t^3 - t)*sqrt(-t^2 + 1) sage: gen_legendre_P(7, 3, I).expand() -16695*sqrt(2) sage: gen_legendre_P(4, 1, 2.5) diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 6e17e8b1420..f76bf6ff19c 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -2293,7 +2293,7 @@ cdef class NumberFieldElement(FieldElement): sage: SR(b.minpoly()).solve(SR('x'), explicit_solutions=True) [] sage: SR(b) - 1/8*((sqrt(4*(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) - 4/3/(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) + 17) + 5)^2 + 4)*(sqrt(4*(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) - 4/3/(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) + 17) + 5) + 1/8*(sqrt(4*(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) - 4/3/(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) + 17) + 5)^3 + 1/2*sqrt(4*(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) - 4/3/(1/9*sqrt(109)*sqrt(3) + 2)^(1/3) + 17) + 5/2 """ K = self._parent.fraction_field() diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 92f019dedb6..3509a62ea91 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -715,6 +715,15 @@ cdef class Polynomial(CommutativeAlgebraElement): return self.reverse()(a_inverse) / a_inverse**self.degree() except AttributeError: pass + from sage.symbolic.ring import SR + if parent(a) is SR: + if len(x) == 1: + try: + return SR(self(a.pyobject())) + except TypeError: + return SR.zero().add(*(self[i]*a**i for i in xrange(d + 1))) + else: + return SR.zero().add(*(self[i](other_args)*a**i for i in xrange(d + 1))) i = d - 1 if len(x) > 1: @@ -1072,7 +1081,7 @@ cdef class Polynomial(CommutativeAlgebraElement): sage: R. = QQ[] sage: f = x^3 + x sage: g = f._symbolic_(SR); g - (x^2 + 1)*x + x^3 + x sage: g(x=2) 10 diff --git a/src/sage/rings/polynomial/polynomial_zz_pex.pyx b/src/sage/rings/polynomial/polynomial_zz_pex.pyx index 9408b33b613..30640a3385e 100644 --- a/src/sage/rings/polynomial/polynomial_zz_pex.pyx +++ b/src/sage/rings/polynomial/polynomial_zz_pex.pyx @@ -251,7 +251,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template): sage: P. = F[] sage: p = y^4 + x*y^3 + y^2 + (x + 1)*y + x + 1 sage: SR(p) #indirect doctest - (((y + x)*y + 1)*y + x + 1)*y + x + 1 + y^4 + x*y^3 + y^2 + (x + 1)*y + x + 1 sage: p(2) x + 1 sage: p(y=2)