From a4f58d734817e84d4ba5ba16cbd09587fa635f26 Mon Sep 17 00:00:00 2001 From: Ralf Stephan Date: Tue, 30 Aug 2016 10:32:35 +0200 Subject: [PATCH] doctest fixes --- src/doc/en/prep/Calculus.rst | 2 +- .../schemes/elliptic_curves/ell_generic.py | 2 +- src/sage/symbolic/expression.pyx | 40 ++++++++++--------- src/sage/tensor/differential_form_element.py | 4 +- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/doc/en/prep/Calculus.rst b/src/doc/en/prep/Calculus.rst index 109666620da..81b0fed4346 100644 --- a/src/doc/en/prep/Calculus.rst +++ b/src/doc/en/prep/Calculus.rst @@ -308,7 +308,7 @@ help it look nicer in the browser? :: sage: integrate(1/(1+x^5),x) - 1/5*sqrt(5)*(sqrt(5) + 1)*arctan((4*x + sqrt(5) - 1)/sqrt(2*sqrt(5) + 10))/sqrt(2*sqrt(5) + 10) + 1/5*sqrt(5)*(sqrt(5) - 1)*arctan((4*x - sqrt(5) - 1)/sqrt(-2*sqrt(5) + 10))/sqrt(-2*sqrt(5) + 10) - 1/2*(sqrt(5) + 3)*log(2*x^2 - x*(sqrt(5) + 1) + 2)/(5*sqrt(5) + 5) - 1/2*(sqrt(5) - 3)*log(2*x^2 + x*(sqrt(5) - 1) + 2)/(5*sqrt(5) - 5) + 1/5*log(x + 1) + 1/5*sqrt(5)*(sqrt(5) + 1)*arctan((4*x + sqrt(5) - 1)/sqrt(2*sqrt(5) + 10))/sqrt(2*sqrt(5) + 10) + 1/5*sqrt(5)*(sqrt(5) - 1)*arctan((4*x - sqrt(5) - 1)/sqrt(-2*sqrt(5) + 10))/sqrt(-2*sqrt(5) + 10) - 1/10*(sqrt(5) + 3)*log(2*x^2 - x*(sqrt(5) + 1) + 2)/(sqrt(5) + 1) - 1/10*(sqrt(5) - 3)*log(2*x^2 + x*(sqrt(5) - 1) + 2)/(sqrt(5) - 1) + 1/5*log(x + 1) Some integrals are a little tricky, of course. If Sage doesn't know the whole antiderivative, it returns as much of it as it (more properly, as diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py index f257c4d2073..2464a1505a7 100644 --- a/src/sage/schemes/elliptic_curves/ell_generic.py +++ b/src/sage/schemes/elliptic_curves/ell_generic.py @@ -385,7 +385,7 @@ def _symbolic_(self, SR): 0 sage: 2*w - (-2*pi + (2*pi - 3*pi^2 + 10)^2/(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1 : (3*pi - (2*pi - 3*pi^2 + 10)^2/(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1)*(2*pi - 3*pi^2 + 10)/sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1) + (-2*pi - (2*pi - 3*pi^2 + 10)^2/(40*pi - 4*pi^3 + 4*pi^2 + 79) + 1 : (3*pi + (2*pi - 3*pi^2 + 10)^2/(40*pi - 4*pi^3 + 4*pi^2 + 79) - 1)*(2*pi - 3*pi^2 + 10)/sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1) sage: x, y, z = 2*w; temp = ((y^2 + y) - (x^3 - x^2 - 10*x - 20)) diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index dbe6aecd084..a5e135693e5 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -3579,22 +3579,6 @@ cdef class Expression(CommutativeRingElement): TESTS:: - sage: (Mod(2,7)*x^2 + Mod(2,7))^7 - (2*x^2 + 2)^7 - - The leading coefficient in the result above is 1 since:: - - sage: t = Mod(2,7); gcd(t, t)^7 - 1 - sage: gcd(t,t).parent() - Ring of integers modulo 7 - - :: - - sage: k = GF(7) - sage: f = expand((k(1)*x^5 + k(1)*x^2 + k(2))^7); f - x^35 + x^14 + 2 - sage: x^oo Traceback (most recent call last): ... @@ -4310,6 +4294,20 @@ cdef class Expression(CommutativeRingElement): sage: ((x+sqrt(2)*x)^2).expand() 2*sqrt(2)*x^2 + 3*x^2 + + Check that exactness is preserved:: + + sage: ((x+1.001)^2).expand() + x^2 + 2.00200000000000*x + 1.00200100000000 + sage: ((x+1.001)^3).expand() + x^3 + 3.00300000000000*x^2 + 3.00600300000000*x + 1.00300300100000 + + Check that :trac:`21302` is fixed:: + + sage: ((x+1)^-2).expand() + 1/(x^2 + 2*x + 1) + sage: (((x-1)/(x+1))^2).expand() + x^2/(x^2 + 2*x + 1) - 2*x/(x^2 + 2*x + 1) + 1/(x^2 + 2*x + 1) """ if side is not None: if not is_a_relational(self._gobj): @@ -5808,8 +5806,8 @@ cdef class Expression(CommutativeRingElement): The behaviour is undefined with noninteger or negative exponents:: - sage: p = (17/3*a)*x^(3/2) + x*y + 1/x + x^x + 5*x^y - sage: rset = set([(1, -1), (y, 1), (17/3*a, 3/2), (x^x, 0), (5, y)]) + sage: p = (17/3*a)*x^(3/2) + x*y + 1/x + 2*x^x + 5*x^y + sage: rset = set([(1, -1), (y, 1), (17/3*a, 3/2), (2, x), (5, y)]) sage: all([(pair[0],pair[1]) in rset for pair in p.coefficients(x)]) True sage: p.coefficients(x, sparse=False) @@ -5846,6 +5844,12 @@ cdef class Expression(CommutativeRingElement): sage: f.coefficients(g) [[t, 0], [3, 1], [1, 2]] + Handle bound variable strictly as part of a constant:: + + sage: (sin(1+x)*sin(1+x^2)).coefficients(x) + [[sin(x^2 + 1)*sin(x + 1), 0]] + sage: (sin(1+x)*sin(1+x^2)*x).coefficients(x) + [[sin(x^2 + 1)*sin(x + 1), 1]] """ cdef vector[pair[GEx,GEx]] vec cdef pair[GEx,GEx] gexpair diff --git a/src/sage/tensor/differential_form_element.py b/src/sage/tensor/differential_form_element.py index 0261904533b..6446528c8c7 100644 --- a/src/sage/tensor/differential_form_element.py +++ b/src/sage/tensor/differential_form_element.py @@ -312,9 +312,9 @@ class DifferentialForm(AlgebraElement): sage: form2 1/log(y)*dz + dx + e^cos(x)*dy sage: d(form2) - -(1/y)/log(y)^2*dy/\dz + -e^cos(x)*sin(x)*dx/\dy + -1/(y*log(y)^2)*dy/\dz + -e^cos(x)*sin(x)*dx/\dy sage: form2.diff() - -(1/y)/log(y)^2*dy/\dz + -e^cos(x)*sin(x)*dx/\dy + -1/(y*log(y)^2)*dy/\dz + -e^cos(x)*sin(x)*dx/\dy sage: d(form1) == form1.diff() True