# Ticket #9879: trac_9879-hold-review.patch

File trac_9879-hold-review.patch, 38.8 KB (added by Karl-Dieter Crisman, 12 years ago)

Apply after initial patch

• ## sage/functions/hyperbolic.py

# HG changeset patch
# User Karl-Dieter Crisman <kcrisman@gmail.com>
# Date 1286204449 14400
# Node ID 7a046048d2c46dfb148d36888169928661c9ba60
# Parent  a975651fae5c7ea069e6bd8284d1d474bc16ca20
Trac 9879 - reviewer patch.

Mostly adds documentation that functional notation does/doesn't work and how to 'unhold'; adds some other minor fixes.

diff -r a975651fae5c -r 7a046048d2c4 sage/functions/hyperbolic.py
 a sage: latex(sinh(x)) \sinh\left(x\right) To prevent automatic evaluation, use the hold parameter:: sage: sinh(arccosh(x),hold=True) sinh(arccosh(x)) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: sinh(arccosh(x),hold=True).simplify() sqrt(x - 1)*sqrt(x + 1) """ GinacFunction.__init__(self, "sinh", latex_name=r"\sinh") sage: latex(cosh(x)) \cosh\left(x\right) To prevent automatic evaluation, use the hold parameter:: sage: cosh(arcsinh(x),hold=True) cosh(arcsinh(x)) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: cosh(arcsinh(x),hold=True).simplify() sqrt(x^2 + 1) """ GinacFunction.__init__(self, "cosh", latex_name=r"\cosh") sage: CDF(tanh(pi + I*e)) 0.997524731976 - 0.002790687681*I To prevent automatic evaluation, use the hold parameter:: sage: tanh(arcsinh(x),hold=True) tanh(arcsinh(x)) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: tanh(arcsinh(x),hold=True).simplify() x/sqrt(x^2 + 1) TESTS:: sage: latex(tanh(x)) csch = Function_csch() ########################## # Inverse trig functions # ########################## ################################ # Inverse hyperbolic functions # ################################ class Function_arcsinh(GinacFunction): def __init__(self): sage: arcsinh(1 + I*1.0) 1.06127506190504 + 0.666239432492515*I To prevent automatic evaluation use the hold argument:: sage: arcsinh(-2,hold=True) arcsinh(-2) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: arcsinh(-2,hold=True).simplify() -arcsinh(2) TESTS:: sage: arcsinh(x).operator() sage: cosh(float(arccosh(2))) 2.0 Warning: If the input is real the output will be real or NaN:: .. warning:: If the input is in the complex field or symbolic (which includes rational and integer input), the output will be complex.  However, if the input is a real decimal, the output will be real or NaN.  See the examples for details. :: sage: arccosh(0.5) NaN But evaluation where the input is in the complex field yields a complex output:: sage: arccosh(1/2) arccosh(1/2) sage: arccosh(1/2).n() NaN sage: arccosh(CC(0.5)) 1.04719755119660*I sage: arccosh(0) 1/2*I*pi sage: arccosh(-1) I*pi To prevent automatic evaluation use the hold argument:: sage: arccosh(-1,hold=True) arccosh(-1) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: arccosh(-1,hold=True).simplify() I*pi TESTS:: sage: arctanh(1 + I*1.0) 0.402359478108525 + 1.01722196789785*I To prevent automatic evaluation use the hold argument:: sage: arctanh(-1/2,hold=True) arctanh(-1/2) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: arctanh(-1/2,hold=True).simplify() -arctanh(1/2) TESTS:: sage: arctanh(x).operator()
• ## sage/functions/log.py

diff -r a975651fae5c -r 7a046048d2c4 sage/functions/log.py
 a sage: exp(RDF('2.5')) 12.1824939607 To prevent automatic evaluation, use the hold parameter:: sage: exp(I*pi,hold=True) e^(I*pi) sage: exp(0,hold=True) e^0 To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: exp(0,hold=True).simplify() 1 :: sage: exp(pi*I/2) Test simplifications when taking powers of exp, #7264:: sage: var('a,b,c,I') (a, b, c, I) sage: model_exp = exp(I)**a*(b) sage: var('a,b,c,II') (a, b, c, II) sage: model_exp = exp(II)**a*(b) sage: sol1_l={b: 5.0, a: 1.1} sage: model_exp.subs(sol1_l) 5.00000000000000*(e^I)^1.10000000000000 5.00000000000000*(e^II)^1.10000000000000 :: sage: exp(3)^I*exp(x) (e^3)^I*e^x sage: exp(3)^II*exp(x) (e^3)^II*e^x sage: exp(x)*exp(x) e^(2*x) sage: exp(x)*exp(a) sage: ln(complex(-1)) 3.1415926535897931j We do not currently support a hold parameter in functional notation:: sage: log(SR(-1),hold=True) Traceback (most recent call last): ... TypeError: log() got an unexpected keyword argument 'hold' This is possible with method notation:: sage: I.log(hold=True) log(I) sage: I.log(hold=True).simplify() 1/2*I*pi TESTS:: sage: latex(x.log())
• ## sage/functions/other.py

diff -r a975651fae5c -r 7a046048d2c4 sage/functions/other.py
 a sage: gamma1(int(5)) 24 :: sage: plot(gamma1(x),(x,1,5)) To prevent automatic evaluation use the hold argument:: sage: gamma1(1/2,hold=True) gamma(1/2) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: gamma1(1/2,hold=True).simplify() sqrt(pi) TESTS: We verify that we can convert this function to Maxima and sage: factorial(x)^2 factorial(x)^2 :: To prevent automatic evaluation use the hold argument:: sage: factorial(5,hold=True) factorial(5) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: factorial(5,hold=True).simplify() 120 We can also give input other than nonnegative integers.  For other nonnegative numbers, the :func:gamma function is used:: sage: factorial(1/2) 1/2*sqrt(pi) sage: factorial(3/4) gamma(7/4) sage: factorial(2.3) 2.68343738195577 But negative input always fails:: sage: factorial(-32) Traceback (most recent call last): sage: binomial(k,i) binomial(k, i) We can use a hold parameter to prevent automatic evaluation, but only using method notation:: sage: SR(5).binomial(3, hold=True) binomial(5, 3) sage: SR(5).binomial(3, hold=True).simplify() 10 TESTS: We verify that we can convert this function to Maxima and bring it back into Sage. -  all - bool (default: False); if True, return all square roots of self, instead of just one. EXAMPLES: EXAMPLES:: This illustrates that the bug reported in #6171 has been fixed:: sage: a = 1.1 sage: a.sqrt(prec=100)  # this is supposed to fail Traceback (most recent call last): ... TypeError: sqrt() got an unexpected keyword argument 'prec' sage: sqrt(a, prec=100) 1.0488088481701515469914535137 sage: sqrt(4.00, prec=250) 2.0000000000000000000000000000000000000000000000000000000000000000000000000 sage: sqrt(-1) I sage: sqrt(2) sqrt(x^2) sage: sqrt(2).n() 1.41421356237310 To prevent automatic evaluation, one can use the hold parameter after coercing to the symbolic ring:: sage: sqrt(SR(4),hold=True) sqrt(4) sage: sqrt(4,hold=True) Traceback (most recent call last): ... TypeError: _do_sqrt() got an unexpected keyword argument 'hold' This illustrates that the bug reported in #6171 has been fixed:: sage: a = 1.1 sage: a.sqrt(prec=100)  # this is supposed to fail Traceback (most recent call last): ... TypeError: sqrt() got an unexpected keyword argument 'prec' sage: sqrt(a, prec=100) 1.0488088481701515469914535137 sage: sqrt(4.00, prec=250) 2.0000000000000000000000000000000000000000000000000000000000000000000000000 One can use numpy input as well:: sage: import numpy sage: a = numpy.arange(2,5) sage: sqrt(a) class Function_real_part(GinacFunction): def __init__(self): r""" Returns the real part of the (possibly complex) input. It is possible to prevent automatic evaluation using the hold parameter:: sage: real_part(I,hold=True) real_part(I) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: real_part(I,hold=True).simplify() 0 EXAMPLES:: sage: z = 1+2*I class Function_imag_part(GinacFunction): def __init__(self): r""" Returns the imaginary part of the (possibly complex) input. It is possible to prevent automatic evaluation using the hold parameter:: sage: imag_part(I,hold=True) imag_part(I) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: imag_part(I,hold=True).simplify() 1 TESTS:: sage: z = 1+2*I class Function_conjugate(GinacFunction): def __init__(self): r""" Returns the complex conjugate of the input. It is possible to prevent automatic evaluation using the hold parameter:: sage: conjugate(I,hold=True) conjugate(I) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: conjugate(I,hold=True).simplify() -I TESTS:: sage: x,y = var('x,y')
• ## sage/functions/special.py

diff -r a975651fae5c -r 7a046048d2c4 sage/functions/special.py
 a 4.78749174278205 sage: log_gamma(x) log_gamma(x) The only current way to prevent automatic evaluation is to use the hold argument with the symbolic method, thus:: sage: SR(5).log_gamma(hold=True) log_gamma(5) To evaluate again, currently we must use numerical evaluation via :meth:n:: sage: a = SR(5).log_gamma(hold=True); a.n() 3.17805383034795 """ try: return t.log_gamma() EXAMPLES:: sage: exp_int(6) doctest:...: DeprecationWarning: The method expint() is deprecated. Use -Ei(-x) or exponential_integral_1(x) as needed instead. doctest:...: DeprecationWarning: The method exp_int() is deprecated. Use -Ei(-x) or exponential_integral_1(x) as needed instead. 0.000360082452162659 """ from sage.misc.misc import deprecation deprecation("The method expint() is deprecated. Use -Ei(-x) or exponential_integral_1(x) as needed instead.") deprecation("The method exp_int() is deprecated. Use -Ei(-x) or exponential_integral_1(x) as needed instead.") try: return t.eint1() except AttributeError:
• ## sage/functions/transcendental.py

diff -r a975651fae5c -r 7a046048d2c4 sage/functions/transcendental.py
 a sage: zeta(I).n() 0.00330022368532410 - 0.418155449141322*I It is possible to use the hold argument to prevent automatic evaluation:: sage: zeta(2,hold=True) zeta(2) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = zeta(2,hold=True); a.simplify() 1/6*pi^2 TESTS:: sage: latex(zeta(x))
• ## sage/functions/trig.py

diff -r a975651fae5c -r 7a046048d2c4 sage/functions/trig.py
 a 0.90929742682568169539601986591 sage: loads(dumps(sin)) sin We can prevent evaluation using the hold parameter:: sage: sin(0,hold=True) sin(0) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = sin(0,hold=True); a.simplify() 0 """ GinacFunction.__init__(self, "sin", latex_name=r"\sin", conversions=dict(maxima='sin',mathematica='Sin')) -0.41614683654714238699756822950 sage: loads(dumps(cos)) cos We can prevent evaluation using the hold parameter:: sage: cos(0,hold=True) cos(0) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = cos(0,hold=True); a.simplify() 1 """ GinacFunction.__init__(self, "cos", latex_name=r"\cos", conversions=dict(maxima='cos',mathematica='Cos')) tan(1/2) sage: RR(tan(1/2)) 0.546302489843790 We can prevent evaluation using the hold parameter:: sage: tan(pi/4,hold=True) tan(1/4*pi) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = tan(pi/4,hold=True); a.simplify() 1 """ GinacFunction.__init__(self, "tan", latex_name=r"\tan") sage: latex(sec(x)) \sec\left(x\right) We can prevent evaluation using the hold parameter:: sage: sec(pi/4,hold=True) sec(1/4*pi) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = sec(pi/4,hold=True); a.simplify() sqrt(2) """ BuiltinFunction.__init__(self, "sec", latex_name=r"\sec") sage: latex(csc(x)) \csc\left(x\right) We can prevent evaluation using the hold parameter:: sage: csc(pi/4,hold=True) csc(1/4*pi) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = csc(pi/4,hold=True); a.simplify() sqrt(2) """ BuiltinFunction.__init__(self, "csc", latex_name=r"\csc") sage: latex(cot(x)) \cot\left(x\right) We can prevent evaluation using the hold parameter:: sage: cot(pi/4,hold=True) cot(1/4*pi) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = cot(pi/4,hold=True); a.simplify() 1 """ BuiltinFunction.__init__(self, "cot", latex_name=r"\cot") sage: arcsin(1 + 1.0*I) 0.666239432492515 + 1.06127506190504*I We can delay evaluation using the hold parameter:: sage: arcsin(0,hold=True) arcsin(0) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = arcsin(0,hold=True); a.simplify() 0 TESTS:: sage: arcsin(x).operator() sage: arccos(3/4).n(100) 0.72273424781341561117837735264 We can delay evaluation using the hold parameter:: sage: arccos(0,hold=True) arccos(0) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = arccos(0,hold=True); a.simplify() 1/2*pi TESTS:: sage: arccos(x).operator() sage: arctan(1/2).n(100) 0.46364760900080611621425623146 We can delay evaluation using the hold parameter:: sage: arctan(0,hold=True) arctan(0) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = arctan(0,hold=True); a.simplify() 0 TESTS:: sage: arctan(x).operator() 1.10714871779 sage: arccot(1 + I) arccot(I + 1) We can delay evaluation using the hold parameter:: sage: arccot(1,hold=True) arccot(1) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = arccot(1,hold=True); a.simplify() 1/4*pi """ BuiltinFunction.__init__(self, "arccot", latex_name=r'{\rm arccot}', conversions=dict(maxima='acot')) 0.523598775598 sage: arccsc(1 + I) arccsc(I + 1) We can delay evaluation using the hold parameter:: sage: arccsc(1,hold=True) arccsc(1) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = arccsc(1,hold=True); a.simplify() 1/2*pi """ BuiltinFunction.__init__(self, "arccsc", latex_name=r'{\rm arccsc}', conversions=dict(maxima='acsc')) 1.0471975512 sage: arcsec(1 + I) arcsec(I + 1) We can delay evaluation using the hold parameter:: sage: arcsec(1,hold=True) arcsec(1) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: a = arcsec(1,hold=True); a.simplify() 0 """ BuiltinFunction.__init__(self, "arcsec", latex_name=r'{\rm arcsec}', conversions=dict(maxima='asec')) sage: arctan2(2,3).n(100) 0.58800260354756755124561108063 We can delay evaluation using the hold parameter:: sage: arctan2(-1/2,1,hold=True) arctan2(-1/2, 1) To then evaluate again, we currently must use Maxima via :meth:sage.symbolic.expression.Expression.simplify:: sage: arctan2(-1/2,1,hold=True).simplify() -arctan(1/2) The function also works with numpy arrays as input:: sage: import numpy
• ## sage/symbolic/expression.pyx

diff -r a975651fae5c -r 7a046048d2c4 sage/symbolic/expression.pyx
 a x^4 sage: (x^2).power(2, hold=True) (x^2)^2 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = (x^2).power(2, hold=True); a.simplify() x^4 """ cdef Expression nexp = self.coerce_in(exp) return new_Expression_from_GEx(self._parent, x + x + (x + 2) + x sage: x.add(x, (2+x), x, 2*x, hold=True) x + x + (x + 2) + x + 2*x To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = x.add(x, hold=True); a.simplify() 2*x """ nargs = [self.coerce_in(x) for x in args] cdef GExVector vec x*x*(x + 2)*x sage: x.mul(x, (2+x), x, 2*x, hold=True) x*x*(x + 2)*x*(2*x) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = x.mul(x, hold=True); a.simplify() x^2 """ nargs = [self.coerce_in(x) for x in args] cdef GExVector vec sage: R(f) 2.7182818284590452353602874714*x^3 + 3.1415926535897932384626433833*y^3 + 1.4142135623730950488016887242 + 1.0000000000000000000000000000*I Using the hold parameter it is possible to prevent automatic evaluation:: sage: SR(I).conjugate(hold=True) conjugate(I) TESTS: This shows that the issue at trac #5755 is fixed (attempting to sage: type(abs(SR(-5))) Using the hold parameter it is possible to prevent automatic evaluation:: Because this overrides a Python builtin function, we do not currently support a hold parameter to prevent automatic evaluation:: sage: abs(SR(-5),hold=True) Traceback (most recent call last): ... TypeError: abs() takes no keyword arguments But this is possible using the method :meth:abs:: sage: SR(-5).abs(hold=True) abs(-5) sage: SR(-5).abs(hold=True) abs(-5) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(-5).abs(hold=True); a.simplify() 5 """ return new_Expression_from_GEx(self._parent, g_hold_wrapper(g_abs, self._gobj, hold)) 1 sage: SR(2).step(hold=True) step(2) """ return new_Expression_from_GEx(self._parent, g_hold_wrapper(g_step, self._gobj, hold)) sage: SR(I).csgn(hold=True) csgn(I) """ return new_Expression_from_GEx(self._parent, g_hold_wrapper(g_csgn, self._gobj, hold)) -I sage: ( 1+I  + (2-3*I)*x).conjugate() (3*I + 2)*conjugate(x) - I + 1 Using the hold parameter it is possible to prevent automatic evaluation:: sage: SR(I).conjugate(hold=True) conjugate(I) This also works in functional notation:: sage: conjugate(I) -I sage: conjugate(I,hold=True) conjugate(I) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(I).conjugate(hold=True); a.simplify() -I """ return new_Expression_from_GEx(self._parent, g_hold_wrapper(g_conjugate, self._gobj, hold)) 2 sage: SR(2).real_part(hold=True) real_part(2) This also works using functional notation:: sage: real_part(I,hold=True) real_part(I) sage: real_part(I) 0 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(2).real_part(hold=True); a.simplify() 2 """ return new_Expression_from_GEx(self._parent, g_hold_wrapper(g_real_part, self._gobj, hold)) sage: I.imag_part(hold=True) imag_part(I) This also works using functional notation:: sage: imag_part(I,hold=True) imag_part(I) sage: imag_part(I) 1 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = I.imag_part(hold=True); a.simplify() 1 TESTS:: sage: x = var('x') 2 sage: SR(4).sqrt(hold=True) sqrt(4) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(4).sqrt(hold=True); a.simplify() 2 To use this parameter in functional notation, you must coerce to the symbolic ring:: sage: sqrt(SR(4),hold=True) sqrt(4) sage: sqrt(4,hold=True) Traceback (most recent call last): ... TypeError: _do_sqrt() got an unexpected keyword argument 'hold' """ return new_Expression_from_GEx(self._parent, g_hold2_wrapper(g_power_construct, self._gobj, g_ex1_2, hold)) sage: SR(0).sin(hold=True) sin(0) This also works using functional notation:: sage: sin(0,hold=True) sin(0) sage: sin(0) 0 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(0).sin(hold=True); a.simplify() 0 TESTS:: sage: SR(oo).sin() sage: pi.cos(hold=True) cos(pi) This also works using functional notation:: sage: cos(pi,hold=True) cos(pi) sage: cos(pi) -1 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = pi.cos(hold=True); a.simplify() -1 TESTS:: sage: SR(oo).cos() sage: (pi/12).tan(hold=True) tan(1/12*pi) This also works using functional notation:: sage: tan(pi/12,hold=True) tan(1/12*pi) sage: tan(pi/12) -sqrt(3) + 2 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = (pi/12).tan(hold=True); a.simplify() -sqrt(3) + 2 TESTS:: sage: SR(oo).tan() sage: SR(0).arcsin(hold=True) arcsin(0) This also works using functional notation:: sage: arcsin(0,hold=True) arcsin(0) sage: arcsin(0) 0 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(0).arcsin(hold=True); a.simplify() 0 TESTS:: sage: SR(oo).arcsin() sage: SR(1).arccos(hold=True) arccos(1) This also works using functional notation:: sage: arccos(1,hold=True) arccos(1) sage: arccos(1) 0 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(1).arccos(hold=True); a.simplify() 0 TESTS:: sage: SR(oo).arccos() sage: SR(1).arctan(hold=True) arctan(1) This also works using functional notation:: sage: arctan(1,hold=True) arctan(1) sage: arctan(1) 1/4*pi To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(1).arctan(hold=True); a.simplify() 1/4*pi TESTS:: sage: SR(oo).arctan() sage: SR(1/2).arctan2(1/2, hold=True) arctan2(1/2, 1/2) This also works using functional notation:: sage: arctan2(1,2,hold=True) arctan2(1, 2) sage: arctan2(1,2) arctan(1/2) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(1/2).arctan2(1/2, hold=True); a.simplify() 1/4*pi TESTS: We compare a bunch of different evaluation points between sage: arccosh(x).sinh(hold=True) sinh(arccosh(x)) This also works using functional notation:: sage: sinh(arccosh(x),hold=True) sinh(arccosh(x)) sage: sinh(arccosh(x)) sqrt(x - 1)*sqrt(x + 1) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = arccosh(x).sinh(hold=True); a.simplify() sqrt(x - 1)*sqrt(x + 1) TESTS:: sage: SR(oo).sinh() sage: arcsinh(x).cosh(hold=True) cosh(arcsinh(x)) This also works using functional notation:: sage: cosh(arcsinh(x),hold=True) cosh(arcsinh(x)) sage: cosh(arcsinh(x)) sqrt(x^2 + 1) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = arcsinh(x).cosh(hold=True); a.simplify() sqrt(x^2 + 1) TESTS:: sage: SR(oo).cosh() sage: arcsinh(x).tanh(hold=True) tanh(arcsinh(x)) This also works using functional notation:: sage: tanh(arcsinh(x),hold=True) tanh(arcsinh(x)) sage: tanh(arcsinh(x)) x/sqrt(x^2 + 1) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = arcsinh(x).tanh(hold=True); a.simplify() x/sqrt(x^2 + 1) TESTS:: sage: SR(oo).tanh() sage: SR(-2).arcsinh(hold=True) arcsinh(-2) This also works using functional notation:: sage: arcsinh(-2,hold=True) arcsinh(-2) sage: arcsinh(-2) -arcsinh(2) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(-2).arcsinh(hold=True); a.simplify() -arcsinh(2) TESTS:: sage: SR(oo).arcsinh() sage: SR(-1).arccosh(hold=True) arccosh(-1) This also works using functional notation:: sage: arccosh(-1,hold=True) arccosh(-1) sage: arccosh(-1) I*pi To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(-1).arccosh(hold=True); a.simplify() I*pi TESTS:: sage: SR(oo).arccosh() sage: SR(-1/2).arctanh(hold=True) arctanh(-1/2) This also works using functional notation:: sage: arctanh(-1/2,hold=True) arctanh(-1/2) sage: arctanh(-1/2) -arctanh(1/2) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(-1/2).arctanh(hold=True); a.simplify() -arctanh(1/2) TESTS:: sage: SR(1).arctanh() sage: (pi*I).exp(hold=True) e^(I*pi) This also works using functional notation:: sage: exp(I*pi,hold=True) e^(I*pi) sage: exp(I*pi) -1 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = (pi*I).exp(hold=True); a.simplify() -1 TESTS: Test if #6377 is fixed:: sage: I.log(hold=True) log(I) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = I.log(hold=True); a.simplify() 1/2*I*pi We do not currently support a hold parameter in functional notation:: sage: log(SR(-1),hold=True) Traceback (most recent call last): ... TypeError: log() got an unexpected keyword argument 'hold' TESTS:: sage: SR(oo).log() sage: SR(2).zeta(hold=True) zeta(2) This also works using functional notation:: sage: zeta(2,hold=True) zeta(2) sage: zeta(2) 1/6*pi^2 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(2).zeta(hold=True); a.simplify() 1/6*pi^2 TESTS:: sage: t = SR(1).zeta(); t sage: SR(5).factorial(hold=True) factorial(5) This also works using functional notation:: sage: factorial(5,hold=True) factorial(5) sage: factorial(5) 120 To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(5).factorial(hold=True); a.simplify() 120 """ _sig_on cdef GEx x = g_hold_wrapper(g_factorial, self._gobj, hold) sage: SR(5).binomial(3, hold=True) binomial(5, 3) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(5).binomial(3, hold=True); a.simplify() 10 We do not currently support a hold parameter in functional notation:: sage: binomial(5,3, hold=True) Traceback (most recent call last): ... TypeError: binomial() got an unexpected keyword argument 'hold' TESTS: Check if we handle zero correctly (#8561):: """ Return the Gamma function evaluated at self. EXAMPLES: EXAMPLES:: sage: x = var('x') sage: x.gamma() gamma(x) sage: SR(CDF(1,1)).gamma() 0.498015668118 - 0.154949828302*I :: sage: gp('gamma(1+I)') # 32-bit 0.4980156681183560427136911175 - 0.1549498283018106851249551305*I :: sage: gp('gamma(1+I)') # 64-bit 0.49801566811835604271369111746219809195 - 0.15494982830181068512495513048388660520*I We plot the familiar plot of this log-convex function:: sage: plot(gamma(x), -6,4).show(ymin=-3,ymax=3) To prevent automatic evaluation use the hold argument:: sage: SR(1/2).gamma() sage: SR(1/2).gamma(hold=True) gamma(1/2) :: sage: set_verbose(-1); plot(lambda x: SR(x).gamma(), -6,4).show(ymin=-3,ymax=3) This also works using functional notation:: sage: gamma(1/2,hold=True) gamma(1/2) sage: gamma(1/2) sqrt(pi) To then evaluate again, we currently must use Maxima via :meth:simplify:: sage: a = SR(1/2).gamma(hold=True); a.simplify() sqrt(pi) """ _sig_on cdef GEx x = g_hold_wrapper(g_tgamma, self._gobj, hold) sage: SR(5).log_gamma(hold=True) log_gamma(5) To evaluate again, currently we must use numerical evaluation via :meth:n:: sage: a = SR(5).log_gamma(hold=True); a.n() 3.17805383034795 We do not currently support a hold parameter in functional notation:: sage: log_gamma(SR(5),hold=True) Traceback (most recent call last): ... TypeError: log_gamma() got an unexpected keyword argument 'hold' """ _sig_on cdef GEx x = g_hold_wrapper(g_lgamma, self._gobj, hold)