Skip to content

Commit

Permalink
Trac #21369: Update to pynac-0.6.9
Browse files Browse the repository at this point in the history
Changelog:
 * fix bug affecting Cygwin compile (#21265)
 * combine some numerics in nested powers; (#21360)
 * fix and clean up `ex::coefficients()` (#20455)
 * `expand()` denominators too (#21302)
 * make `ex::combine_fractions()` recursive (#20858)
 * more `normal()` options (#21335)
 * Appell F1 function skeleton
 * updates from GiNaC

https://github.com/pynac/pynac/releases/download/pynac-0.6.9/pynac-0.6.9
.tar.bz2

URL: https://trac.sagemath.org/21369
Reported by: rws
Ticket author(s): Ralf Stephan, Erik M. Bray, Jeroen Demeyer
Reviewer(s): Jeroen Demeyer, Ralf Stephan
  • Loading branch information
Release Manager authored and vbraun committed Sep 3, 2016
2 parents ace6c00 + b06cfa0 commit d857858
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 21 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/pynac/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=pynac-VERSION.tar.bz2
sha1=d6d19ffeb50333223e93e1a07ff1448817d31a61
md5=c132dc9a661e4d73f01c1966758d3fd2
cksum=605014649
sha1=0ff1bb3502024b5dc606fbc0068e18512ec5ced9
md5=8a7d8c5db32bc71b095c5ec80ca245db
cksum=4248608954
2 changes: 1 addition & 1 deletion build/pkgs/pynac/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.8
0.6.9
2 changes: 1 addition & 1 deletion src/doc/en/prep/Calculus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/ell_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
71 changes: 60 additions & 11 deletions src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,12 @@ cdef class Expression(CommutativeRingElement):
1.54308063481524
sage: float(cos(I))
1.5430806348152437

TESTS::

sage: e = sqrt(2)/sqrt(abs(-(I - 1)*sqrt(2) - I - 1))
sage: e._eval_self(float)
0.9036020036...
"""
cdef GEx res
try:
Expand All @@ -1200,7 +1206,13 @@ cdef class Expression(CommutativeRingElement):
raise err
res = self._gobj.evalf(0, {'parent':R_complex})
if is_a_numeric(res):
return R(py_object_from_numeric(res))
ans = py_object_from_numeric(res)
# Convert ans to R.
if R is float and isinstance(ans, complex) and not ans.imag:
# Python does not automatically convert "real" complex
# numbers to floats, so we do this manually:
ans = ans.real
return R(ans)
else:
raise TypeError("Cannot evaluate symbolic expression to a numeric value.")

Expand Down Expand Up @@ -1386,6 +1398,11 @@ cdef class Expression(CommutativeRingElement):
Traceback (most recent call last):
...
TypeError: unable to simplify to float approximation

TESTS::

sage: float(sqrt(2)/sqrt(abs(-(I - 1)*sqrt(2) - I - 1)))
0.9036020036...
"""
try:
return float(self._eval_self(float))
Expand Down Expand Up @@ -3552,8 +3569,6 @@ cdef class Expression(CommutativeRingElement):
INPUT:

- ``exp`` -- something that coerces to a symbolic expression.
- ``ignored`` -- the second argument that should accept a modulus
is actually ignored.

OUTPUT:

Expand Down Expand Up @@ -3585,7 +3600,7 @@ cdef class Expression(CommutativeRingElement):
::

sage: k = GF(7)
sage: f = expand((k(1)*x^5 + k(1)*x^2 + k(2))^7); f
sage: f = expand((k(1)*x^5 + k(1)*x^2 + k(2))^7); f # known bug
x^35 + x^14 + 2

sage: x^oo
Expand Down Expand Up @@ -4303,6 +4318,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):
Expand Down Expand Up @@ -5801,8 +5830,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)
Expand Down Expand Up @@ -5839,6 +5868,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
Expand Down Expand Up @@ -8350,11 +8385,14 @@ cdef class Expression(CommutativeRingElement):
else:
return v[0]

def combine(self):
def combine(self, bint deep=False):
r"""
Return a simplified version of this symbolic expression
by combining all terms with the same denominator into a single
term.
by combining all toplevel terms with the same denominator into
a single term.

Please use the keyword ``deep=True`` to apply the process
recursively.

EXAMPLES::

Expand All @@ -8364,8 +8402,19 @@ cdef class Expression(CommutativeRingElement):
(x - 1)*x/(x^2 - 7) + y^2/(x^2 - 7) + b/a + c/a + 1/(x + 1)
sage: f.combine()
((x - 1)*x + y^2)/(x^2 - 7) + (b + c)/a + 1/(x + 1)
sage: (1/x + 1/x^2 + (x+1)/x).combine()
(x + 2)/x + 1/x^2
sage: ex = 1/x + ((x + 1)/x - 1/x)/x^2 + (x+1)/x; ex
(x + 1)/x + 1/x + ((x + 1)/x - 1/x)/x^2
sage: ex.combine()
(x + 2)/x + ((x + 1)/x - 1/x)/x^2
sage: ex.combine(deep=True)
(x + 2)/x + 1/x^2
sage: (1+sin((x + 1)/x - 1/x)).combine(deep=True)
sin(1) + 1
"""
return new_Expression_from_GEx(self._parent, self._gobj.combine_fractions())
return new_Expression_from_GEx(self._parent,
self._gobj.combine_fractions(deep))

def normalize(self):
"""
Expand Down Expand Up @@ -8408,7 +8457,7 @@ cdef class Expression(CommutativeRingElement):
ALGORITHM: Uses GiNaC.

"""
return new_Expression_from_GEx(self._parent, self._gobj.normal())
return new_Expression_from_GEx(self._parent, self._gobj.normal(0, False, True))

def numerator(self, bint normalize = True):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/symbolic/ginac.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ cdef extern from "sage/symbolic/ginac_wrap.h":
GEx lcoeff(GEx expr) except +
GEx tcoeff(GEx expr) except +
void coefficients(GEx s, vector[pair[GEx,GEx]]) except +
GEx combine_fractions() except +
GEx normal() except +
GEx combine_fractions(bint deep) except +
GEx normal(int level, bint noexpand_combined, bint noexpand_frac) except +
GEx numer() except +
GEx denom() except +
GEx numer_denom() except +
Expand Down
4 changes: 2 additions & 2 deletions src/sage/tensor/differential_form_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d857858

Please sign in to comment.