Skip to content

Commit

Permalink
Trac #20134: Upgrade to pynac-0.6.4
Browse files Browse the repository at this point in the history
Newest pynac does:
* fix `Re/Im(tanh)` (#20098) (R. Stephan)
* fix positive+integer assumption conflicts (#20132) (A. Thakkar)
* from GiNaC: [bugfix] fix elusive bug in quo, rem,... (R. Kreckel)
* from GiNaC: [bugfix] fix sqrfree(poly) for zero polynomials in
disguise. (R. Kreckel)
* sin/cos/tan of numeric: reduce mod `2*pi` (#20099) (B. Hackl)
* more trigonometric simplifications (#20099) (B. Hackl, R. Stephan)
* always expand function arguments (B. Hackl)
* exp of numeric: reduce mod `2*pi*I` (#20099) (B. Hackl)
* performance: speed up sin/cos/tan/coth/acoth evaluation (R. Stephan,
A. Thakkar)
* performance: GiNaC functions for coth/sech/csch/acoth/asech/acsch (R.
Stephan, A. Thakkar)
* AUTHORS updated

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

URL: http://trac.sagemath.org/20134
Reported by: rws
Ticket author(s): Ralf Stephan
Reviewer(s): Jeroen Demeyer
  • Loading branch information
Release Manager authored and vbraun committed Mar 20, 2016
2 parents 9ee55d0 + 9cbedc7 commit f62fc0c
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 184 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=fe11b0fe2345eb16b3988077707d86c1b8fa0fd3
md5=71edb1a2fb003b6c16abda4a0d73c3cf
cksum=1406756294
sha1=fb0c8f83159b1c9c92dcb335409f12250726a32d
md5=593ac3752f8293199ffc097becbebfcf
cksum=4163433737
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.2
0.6.4
228 changes: 65 additions & 163 deletions src/sage/functions/hyperbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def __init__(self):
tanh = Function_tanh()


class Function_coth(HyperbolicFunction):
class Function_coth(GinacFunction):
def __init__(self):
r"""
The hyperbolic cotangent function.
Expand All @@ -204,45 +204,33 @@ def __init__(self):
sage: coth(pi)
coth(pi)
sage: coth(3.1415)
1.00374256795520
sage: float(coth(pi))
1.0037418731973213
sage: RR(coth(pi))
1.00374187319732
sage: latex(coth(x))
\coth\left(x\right)
"""
HyperbolicFunction.__init__(self, "coth", latex_name=r"\coth",
evalf_float=lambda x: 1/math.tanh(x))

def _eval_(self, x):
"""
EXAMPLES::
sage: coth(0)
+Infinity
Infinity
sage: coth(pi*I)
+Infinity
Infinity
sage: coth(pi*I/2)
0
sage: coth(7*pi*I/2)
0
sage: coth(8*pi*I/2)
+Infinity
Infinity
sage: coth(7.*pi*I/2)
coth(3.50000000000000*I*pi)
-I*cot(3.50000000000000*pi)
sage: coth(3.1415)
1.00374256795520
sage: float(coth(pi))
1.0037418731973213
sage: RR(coth(pi))
1.00374187319732
sage: bool(diff(coth(x), x) == diff(1/tanh(x), x))
True
sage: diff(coth(x), x)
-1/sinh(x)^2
sage: latex(coth(x))
\operatorname{coth}\left(x\right)
"""
if x.is_zero():
return Infinity
if isinstance(x, Expression):
y = 2 * x / pi / I
if y.is_integer():
if ZZ(y) % 2 == 1:
return 0
else:
return Infinity
GinacFunction.__init__(self, "coth", latex_name=r"\operatorname{coth}")

def _eval_numpy_(self, x):
"""
Expand All @@ -255,22 +243,10 @@ def _eval_numpy_(self, x):
"""
return 1 / tanh(x)

def _derivative_(self, *args, **kwds):
"""
EXAMPLES::
sage: bool(diff(coth(x), x) == diff(1/tanh(x), x))
True
sage: diff(coth(x), x)
-csch(x)^2
"""
x = args[0]
return -csch(x)**2

coth = Function_coth()


class Function_sech(HyperbolicFunction):
class Function_sech(GinacFunction):
def __init__(self):
r"""
The hyperbolic secant function.
Expand All @@ -285,39 +261,27 @@ def __init__(self):
0.0862667383340544...
sage: RR(sech(pi))
0.0862667383340544
sage: latex(sech(x))
{\rm sech}\left(x\right)
"""
HyperbolicFunction.__init__(self, "sech", latex_name=r"{\rm sech}",
evalf_float=lambda x: 1/math.cosh(x))

def _eval_(self, x):
"""
EXAMPLES::
sage: sech(0)
1
sage: sech(pi*I)
-1
sage: sech(pi*I/2)
+Infinity
Infinity
sage: sech(7*pi*I/2)
+Infinity
Infinity
sage: sech(8*pi*I/2)
1
sage: sech(8.*pi*I/2)
sech(4.00000000000000*I*pi)
sec(4.00000000000000*pi)
sage: bool(diff(sech(x), x) == diff(1/cosh(x), x))
True
sage: diff(sech(x), x)
-sech(x)*tanh(x)
sage: latex(sech(x))
\operatorname{sech}\left(x\right)
"""
if x.is_zero():
return 1
if isinstance(x, Expression):
y = 2 * x / pi / I
if y.is_integer():
if ZZ(y) % 2 == 1:
return Infinity
else:
return ZZ(-1) ** ZZ(y / 2)
GinacFunction.__init__(self, "sech", latex_name=r"\operatorname{sech}",)

def _eval_numpy_(self, x):
"""
Expand All @@ -330,22 +294,10 @@ def _eval_numpy_(self, x):
"""
return 1 / cosh(x)

def _derivative_(self, *args, **kwds):
"""
EXAMPLES::
sage: bool(diff(sech(x), x) == diff(1/cosh(x), x))
True
sage: diff(sech(x), x)
-sech(x)*tanh(x)
"""
x = args[0]
return -sech(x)*tanh(x)

sech = Function_sech()


class Function_csch(HyperbolicFunction):
class Function_csch(GinacFunction):
def __init__(self):
r"""
The hyperbolic cosecant function.
Expand All @@ -360,37 +312,25 @@ def __init__(self):
0.0865895375300469...
sage: RR(csch(pi))
0.0865895375300470
sage: latex(csch(x))
{\rm csch}\left(x\right)
"""
HyperbolicFunction.__init__(self, "csch", latex_name=r"{\rm csch}",
evalf_float=lambda x: 1/math.sinh(x))

def _eval_(self, x):
"""
EXAMPLES::
sage: csch(0)
+Infinity
Infinity
sage: csch(pi*I)
+Infinity
Infinity
sage: csch(pi*I/2)
-I
sage: csch(7*pi*I/2)
I
sage: csch(7.*pi*I/2)
csch(3.50000000000000*I*pi)
-I*csc(3.50000000000000*pi)
sage: bool(diff(csch(x), x) == diff(1/sinh(x), x))
True
sage: diff(csch(x), x)
-coth(x)*csch(x)
sage: latex(csch(x))
{\rm csch}\left(x\right)
"""
if x.is_zero():
return Infinity
if isinstance(x, Expression):
y = 2 * x / pi / I
if y.is_integer():
if ZZ(y) % 2 == 1:
return ZZ(-1) ** ZZ((y + 1) / 2) * I
else:
return Infinity
GinacFunction.__init__(self, "csch", latex_name=r"{\rm csch}")

def _eval_numpy_(self, x):
"""
Expand All @@ -403,18 +343,6 @@ def _eval_numpy_(self, x):
"""
return 1 / sinh(x)

def _derivative_(self, *args, **kwds):
"""
EXAMPLES::
sage: bool(diff(csch(x), x) == diff(1/sinh(x), x))
True
sage: diff(csch(x), x)
-coth(x)*csch(x)
"""
x = args[0]
return -csch(x)*coth(x)

csch = Function_csch()


Expand Down Expand Up @@ -617,7 +545,7 @@ def __init__(self):
arctanh = atanh = Function_arctanh()


class Function_arccoth(HyperbolicFunction):
class Function_arccoth(GinacFunction):
def __init__(self):
r"""
The inverse of the hyperbolic cotangent function.
Expand All @@ -633,6 +561,11 @@ def __init__(self):
sage: arccoth(2).n(200)
0.54930614433405484569762261846126285232374527891137472586735
sage: bool(diff(acoth(x), x) == diff(atanh(x), x))
True
sage: diff(acoth(x), x)
-1/(x^2 - 1)
Using first the `.n(53)` method is slightly more precise than
converting directly to a ``float``::
Expand All @@ -646,12 +579,11 @@ def __init__(self):
TESTS::
sage: latex(arccoth(x))
{\rm arccoth}\left(x\right)
\operatorname{arccoth}\left(x\right)
"""
HyperbolicFunction.__init__(self, "arccoth",
latex_name=r"{\rm arccoth}",
conversions=dict(maxima='acoth', sympy='acoth'),
evalf_float=lambda x: atanh(float(1/x)))
GinacFunction.__init__(self, "arccoth",
latex_name=r"\operatorname{arccoth}",
conversions=dict(maxima='acoth', sympy='acoth'))

def _eval_numpy_(self, x):
"""
Expand All @@ -664,22 +596,10 @@ def _eval_numpy_(self, x):
"""
return arctanh(1.0 / x)

def _derivative_(self, *args, **kwds):
"""
EXAMPLES::
sage: bool(diff(acoth(x), x) == diff(atanh(x), x))
True
sage: diff(acoth(x), x)
-1/(x^2 - 1)
"""
x = args[0]
return -1/(x**2 - 1)

arccoth = acoth = Function_arccoth()


class Function_arcsech(HyperbolicFunction):
class Function_arcsech(GinacFunction):
def __init__(self):
r"""
The inverse of the hyperbolic secant function.
Expand All @@ -697,12 +617,13 @@ def __init__(self):
sage: float(arcsech(1/2))
1.3169578969248168
sage: diff(asech(x), x)
-1/(sqrt(-x^2 + 1)*x)
sage: latex(arcsech(x))
{\rm arcsech}\left(x\right)
\operatorname{arcsech}\left(x\right)
"""
HyperbolicFunction.__init__(self, "arcsech",
latex_name=r"{\rm arcsech}",
evalf_float=lambda x: acosh(float(1/x)),
GinacFunction.__init__(self, "arcsech",
latex_name=r"\operatorname{arcsech}",
conversions=dict(maxima='asech'))

def _eval_numpy_(self, x):
Expand All @@ -717,20 +638,10 @@ def _eval_numpy_(self, x):
"""
return arccosh(1.0 / x)

def _derivative_(self, *args, **kwds):
"""
EXAMPLES::
sage: diff(asech(x), x)
-1/((x + 1)*x*sqrt(-(x - 1)/(x + 1)))
"""
x = args[0]
return -1/(x * (x+1) * ( (1-x)/(1+x) ).sqrt())

arcsech = asech = Function_arcsech()


class Function_arccsch(HyperbolicFunction):
class Function_arccsch(GinacFunction):
def __init__(self):
r"""
The inverse of the hyperbolic cosecant function.
Expand All @@ -748,12 +659,13 @@ def __init__(self):
sage: float(arccsch(1))
0.881373587019543
sage: diff(acsch(x), x)
-1/(sqrt(x^2 + 1)*x)
sage: latex(arccsch(x))
{\rm arccsch}\left(x\right)
\operatorname{arccsch}\left(x\right)
"""
HyperbolicFunction.__init__(self, "arccsch",
latex_name=r"{\rm arccsch}",
evalf_float=lambda x: arcsinh(float(1/x)),
GinacFunction.__init__(self, "arccsch",
latex_name=r"\operatorname{arccsch}",
conversions=dict(maxima='acsch'))

def _eval_numpy_(self, x):
Expand All @@ -768,14 +680,4 @@ def _eval_numpy_(self, x):
"""
return arcsinh(1.0 / x)

def _derivative_(self, *args, **kwds):
"""
EXAMPLES::
sage: diff(acsch(x), x)
-1/(x^2*sqrt(1/x^2 + 1))
"""
x = args[0]
return -1/(x**2 * (1 + x**(-2)).sqrt())

arccsch = acsch = Function_arccsch()
5 changes: 1 addition & 4 deletions src/sage/functions/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,7 @@ def _eval_(self, *args):
sage: f._eval_(1,1)
tanh(1)
Here arccoth doesn't have 1 in its domain, so we just hold the expression:
sage: elliptic_e(arccoth(1), x^2*e)
sage: elliptic_e(arccoth(1, hold=True), x^2*e)
elliptic_e(arccoth(1), x^2*e)
Since Maxima works only with double precision, numerical
Expand Down
Loading

0 comments on commit f62fc0c

Please sign in to comment.