Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
a42f798 still fails three in expression.pyx
Browse files Browse the repository at this point in the history
  • Loading branch information
rwst committed Mar 3, 2016
1 parent 190a7be commit fcb8d95
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 107 deletions.
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.3
137 changes: 42 additions & 95 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 @@ -287,10 +263,9 @@ def __init__(self):
0.0862667383340544
sage: latex(sech(x))
{\rm sech}\left(x\right)
\operatorname{sech}\left(x\right)
"""
HyperbolicFunction.__init__(self, "sech", latex_name=r"{\rm sech}",
evalf_float=lambda x: 1/math.cosh(x))
GinacFunction.__init__(self, "sech", latex_name=r"\operatorname{sech}",)

def _eval_(self, x):
"""
Expand Down Expand Up @@ -617,7 +592,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 +608,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 +626,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 +643,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 @@ -698,11 +665,10 @@ def __init__(self):
1.3169578969248168
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 +683,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 +704,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 +725,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()
2 changes: 1 addition & 1 deletion src/sage/functions/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def _eval_(self, *args):
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
6 changes: 0 additions & 6 deletions src/sage/symbolic/assumptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class GenericDeclaration(SageObject):
sage: decl = GenericDeclaration(x, 'integer')
sage: decl.assume()
sage: sin(x*pi)
sin(pi*x)
sage: sin(x*pi).simplify()
0
sage: decl.forget()
sage: sin(x*pi)
Expand Down Expand Up @@ -115,8 +113,6 @@ def __init__(self, var, assumption):
sage: decl = GenericDeclaration(x, 'integer')
sage: decl.assume()
sage: sin(x*pi)
sin(pi*x)
sage: sin(x*pi).simplify()
0
sage: decl.forget()
sage: sin(x*pi)
Expand Down Expand Up @@ -425,8 +421,6 @@ def assume(*args):
Simplifying certain well-known identities works as well::
sage: sin(n*pi)
sin(pi*n)
sage: sin(n*pi).simplify()
0
sage: forget()
sage: sin(n*pi).simplify()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3170,7 +3170,7 @@ cdef class Expression(CommutativeRingElement):
sage: (-1.0*x)*(1.0/x)
-1.00000000000000
sage: sin(1.0*pi)
sin(1.00000000000000*pi)
0
"""
cdef GEx x
cdef Expression _right = <Expression>right
Expand Down
6 changes: 3 additions & 3 deletions src/sage/symbolic/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
sage: x = var('x')
sage: m = x == 5*x + 1
sage: n = sin(x) == sin(x+2*pi)
sage: n = sin(x) == sin(x+2*pi, hold=True)
sage: m * n
x*sin(x) == (5*x + 1)*sin(2*pi + x)
sage: m = 2*x == 3*x^2 - 5
Expand All @@ -87,11 +87,11 @@
sage: x = var('x')
sage: m = x == 5*x + 1
sage: n = sin(x) == sin(x+2*pi)
sage: n = sin(x) == sin(x+2*pi, hold=True)
sage: m/n
x/sin(x) == (5*x + 1)/sin(2*pi + x)
sage: m = x != 5*x + 1
sage: n = sin(x) != sin(x+2*pi)
sage: n = sin(x) != sin(x+2*pi, hold=True)
sage: m/n
x/sin(x) != (5*x + 1)/sin(2*pi + x)
Expand Down

0 comments on commit fcb8d95

Please sign in to comment.