Exemple #1
0
    def __init__(self):
        r"""
        The inverse of the hyperbolic secant function.

        EXAMPLES::

            sage: arcsech(0.5)
            1.31695789692482
            sage: arcsech(1/2)
            arcsech(1/2)
            sage: arcsech(1 + I*1.0)
            0.530637530952518 - 1.11851787964371*I
            sage: arcsech(1/2).n(200)
            1.3169578969248167086250463473079684440269819714675164797685
            sage: float(arcsech(1/2))
            1.3169578969248168

            sage: diff(asech(x), x)
            -1/(sqrt(-x^2 + 1)*x)
            sage: latex(arcsech(x))
            \operatorname{arcsech}\left(x\right)
        """
        GinacFunction.__init__(self, "arcsech",
                latex_name=r"\operatorname{arcsech}",
                conversions=dict(maxima='asech'))
Exemple #2
0
    def __init__(self):
        r"""
        The hyperbolic sine function.

        EXAMPLES::

            sage: sinh(pi)
            sinh(pi)
            sage: sinh(3.1415)
            11.5476653707437
            sage: float(sinh(pi))
            11.54873935725774...
            sage: RR(sinh(pi))
            11.5487393572577

            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")
Exemple #3
0
    def __init__(self):
        r"""
        The inverse of the hyperbolic cosecant function.

        EXAMPLES::

            sage: arccsch(2.0)
            0.481211825059603
            sage: arccsch(2)
            arccsch(2)
            sage: arccsch(1 + I*1.0)
            0.530637530952518 - 0.452278447151191*I
            sage: arccsch(1).n(200)
            0.88137358701954302523260932497979230902816032826163541075330
            sage: float(arccsch(1))
            0.881373587019543

            sage: diff(acsch(x), x)
            -1/(sqrt(x^2 + 1)*x)
            sage: latex(arccsch(x))
            \operatorname{arccsch}\left(x\right)
        """
        GinacFunction.__init__(self, "arccsch",
                latex_name=r"\operatorname{arccsch}",
                conversions=dict(maxima='acsch'))
Exemple #4
0
    def __init__(self):
        """
        The cosine function.

        EXAMPLES::

            sage: cos(pi)
            -1
            sage: cos(x).subs(x==pi)
            -1
            sage: cos(2).n(100)
            -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

        TESTS::

            sage: conjugate(cos(x))
            cos(conjugate(x))
        """
        GinacFunction.__init__(self, "cos", latex_name=r"\cos",
                conversions=dict(maxima='cos',mathematica='Cos'))
Exemple #5
0
    def __init__(self):
        """
        The sine function.

        EXAMPLES::

            sage: sin(0)
            0
            sage: sin(x).subs(x==0)
            0
            sage: sin(2).n(100)
            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

        TESTS::

            sage: conjugate(sin(x))
            sin(conjugate(x))
        """
        GinacFunction.__init__(self, "sin", latex_name=r"\sin",
                conversions=dict(maxima='sin',mathematica='Sin'))
Exemple #6
0
    def __init__(self):
        """
        The arcsine function.

        EXAMPLES::

            sage: arcsin(0.5)
            0.523598775598299
            sage: arcsin(1/2)
            1/6*pi
            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

        ``conjugate(arcsin(x))==arcsin(conjugate(x))``, unless on the branch
        cuts which run along the real axis outside the interval [-1, +1].::

            sage: conjugate(arcsin(x))
            conjugate(arcsin(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(arcsin(y))
            conjugate(arcsin(y))
            sage: conjugate(arcsin(y+I))
            conjugate(arcsin(y + I))
            sage: conjugate(arcsin(1/16))
            arcsin(1/16)
            sage: conjugate(arcsin(2))
            conjugate(arcsin(2))
            sage: conjugate(arcsin(-2))
            -conjugate(arcsin(2))

        TESTS::

            sage: arcsin(x)._sympy_()
            asin(x)
            sage: arcsin(x).operator()
            arcsin
            sage: asin(complex(1,1))
            (0.6662394324925152+1.0612750619050357j)

        Check that :trac:`22823` is fixed::

            sage: bool(asin(SR(2.1)) == NaN)
            True
            sage: asin(SR(2.1)).is_real()
            False
        """
        GinacFunction.__init__(self, 'arcsin', latex_name=r"\arcsin",
                conversions=dict(maxima='asin', sympy='asin', fricas="asin", giac="asin"))
Exemple #7
0
    def __init__(self):
        r"""
        The hyperbolic cosecant function.

        EXAMPLES::

            sage: csch(pi)
            csch(pi)
            sage: csch(3.1415)
            0.0865975907592133
            sage: float(csch(pi))
            0.0865895375300469...
            sage: RR(csch(pi))
            0.0865895375300470
            sage: csch(0)
            Infinity
            sage: csch(pi*I)
            Infinity
            sage: csch(pi*I/2)
            -I
            sage: csch(7*pi*I/2)
            I
            sage: csch(7.*pi*I/2)
            -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)
        """
        GinacFunction.__init__(self, "csch", latex_name=r"{\rm csch}")
Exemple #8
0
    def __init__(self):
        r"""
        The hyperbolic secant function.

        EXAMPLES::

            sage: sech(pi)
            sech(pi)
            sage: sech(3.1415)
            0.0862747018248192
            sage: float(sech(pi))
            0.0862667383340544...
            sage: RR(sech(pi))
            0.0862667383340544
            sage: sech(0)
            1
            sage: sech(pi*I)
            -1
            sage: sech(pi*I/2)
            Infinity
            sage: sech(7*pi*I/2)
            Infinity
            sage: sech(8*pi*I/2)
            1
            sage: sech(8.*pi*I/2)
            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)
        """
        GinacFunction.__init__(self, "sech", latex_name=r"\operatorname{sech}",)
Exemple #9
0
    def __init__(self):
        r"""
        The unit step function, ``unit_step(x)``.

        INPUT:

        -  ``x`` - a real number or a symbolic expression

        EXAMPLES::

            sage: unit_step(-1)
            0
            sage: unit_step(1)
            1
            sage: unit_step(0)
            1
            sage: unit_step(x)
            unit_step(x)
            sage: latex(unit_step(x))
            \mathrm{u}\left(x\right)

        TESTS::

            sage: t = loads(dumps(unit_step(x)+1)); t
            unit_step(x) + 1
            sage: t.subs(x=0)
            2
        """
        GinacFunction.__init__(self, "unit_step", latex_name=r"\mathrm{u}",
                                   conversions=dict(mathematica='UnitStep'))
Exemple #10
0
    def __init__(self):
        r"""
        The hyperbolic cosine function.

        EXAMPLES::

            sage: cosh(pi)
            cosh(pi)
            sage: cosh(3.1415)
            11.5908832931176
            sage: float(cosh(pi))
            11.591953275521519
            sage: RR(cosh(1/2))
            1.12762596520638

            sage: latex(cosh(x))
            \cosh\left(x\right)
            sage: cosh(x)._sympy_()
            cosh(x)

        To prevent automatic evaluation, use the ``hold`` parameter::

            sage: cosh(arcsinh(x),hold=True)
            cosh(arcsinh(x))

        To then evaluate again, use the ``unhold`` method::

            sage: cosh(arcsinh(x),hold=True).unhold()
            sqrt(x^2 + 1)
        """
        GinacFunction.__init__(self, "cosh", latex_name=r"\cosh")
Exemple #11
0
    def __init__(self):
        r"""
        The absolute value function.

        EXAMPLES::

            sage: var('x y')
            (x, y)
            sage: abs(x)
            abs(x)
            sage: abs(x^2 + y^2)
            abs(x^2 + y^2)
            sage: abs(-2)
            2
            sage: sqrt(x^2)
            sqrt(x^2)
            sage: abs(sqrt(x))
            abs(sqrt(x))
            sage: complex(abs(3*I))
            (3+0j)

            sage: f = sage.functions.other.Function_abs()
            sage: latex(f)
            \mathrm{abs}
            sage: latex(abs(x))
            {\left| x \right|}
        """
        GinacFunction.__init__(self, "abs", latex_name=r"\mathrm{abs}")
Exemple #12
0
    def __init__(self):
        r"""
        The Heaviside step function, ``heaviside(x)``.

        INPUT:

        -  ``x`` - a real number or a symbolic expression

        EXAMPLES::

            sage: heaviside(-1)
            0
            sage: heaviside(1)
            1
            sage: heaviside(0)
            heaviside(0)
            sage: heaviside(x)
            heaviside(x)
            sage: latex(heaviside(x))
            H\left(x\right)
            sage: heaviside(x)._sympy_()
            Heaviside(x)
            sage: heaviside(x)._giac_()
            Heaviside(x)
            sage: h(x) = heaviside(x)
            sage: h(pi).numerical_approx()
            1.00000000000000
        """
        GinacFunction.__init__(self, "heaviside", latex_name="H",
                                 conversions=dict(maxima='hstep',
                                                  mathematica='HeavisideTheta',
                                                  sympy='Heaviside',
                                                  giac='Heaviside'))
Exemple #13
0
    def __init__(self):
        r"""
        The hyperbolic sine function.

        EXAMPLES::

            sage: sinh(pi)
            sinh(pi)
            sage: sinh(3.1415)
            11.5476653707437
            sage: float(sinh(pi))
            11.54873935725774...
            sage: RR(sinh(pi))
            11.5487393572577

            sage: latex(sinh(x))
            \sinh\left(x\right)
            sage: sinh(x)._sympy_()
            sinh(x)

        To prevent automatic evaluation, use the ``hold`` parameter::

            sage: sinh(arccosh(x),hold=True)
            sinh(arccosh(x))

        To then evaluate again, use the ``unhold`` method::

            sage: sinh(arccosh(x),hold=True).unhold()
            sqrt(x + 1)*sqrt(x - 1)
        """
        GinacFunction.__init__(self, "sinh", latex_name=r"\sinh")
Exemple #14
0
    def __init__(self):
        r"""
        Derivatives of the Riemann zeta function.

        EXAMPLES::

            sage: zetaderiv(1, x)
            zetaderiv(1, x)
            sage: zetaderiv(1, x).diff(x)
            zetaderiv(2, x)
            sage: var('n')
            n
            sage: zetaderiv(n,x)
            zetaderiv(n, x)
            sage: zetaderiv(1, 4).n()
            -0.0689112658961254
            sage: import mpmath; mpmath.diff(lambda x: mpmath.zeta(x), 4)
            mpf('-0.068911265896125382')

        TESTS::

            sage: latex(zetaderiv(2,x))
            \zeta^\prime\left(2, x\right)
            sage: a = loads(dumps(zetaderiv(2,x)))
            sage: a.operator() == zetaderiv
            True
        """
        GinacFunction.__init__(self, "zetaderiv", nargs=2)
Exemple #15
0
    def __init__(self):
        r"""
        The hyperbolic tangent function.

        EXAMPLES::

            sage: tanh(pi)
            tanh(pi)
            sage: tanh(3.1415)
            0.996271386633702
            sage: float(tanh(pi))
            0.99627207622075
            sage: tan(3.1415/4)
            0.999953674278156
            sage: tanh(pi/4)
            tanh(1/4*pi)
            sage: RR(tanh(1/2))
            0.462117157260010

        ::

            sage: CC(tanh(pi + I*e))
            0.997524731976164 - 0.00279068768100315*I
            sage: ComplexField(100)(tanh(pi + I*e))
            0.99752473197616361034204366446 - 0.0027906876810031453884245163923*I
            sage: CDF(tanh(pi + I*e))  # rel tol 2e-15
            0.9975247319761636 - 0.002790687681003147*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))
            \tanh\left(x\right)
            sage: tanh(x)._sympy_()
            tanh(x)

        Check that real/imaginary parts are correct (:trac:`20098`)::

            sage: tanh(1+2*I).n()
            1.16673625724092 - 0.243458201185725*I
            sage: tanh(1+2*I).real().n()
            1.16673625724092
            sage: tanh(1+2*I).imag().n()
            -0.243458201185725
            sage: tanh(x).real()
            sinh(2*real_part(x))/(cos(2*imag_part(x)) + cosh(2*real_part(x)))
            sage: tanh(x).imag()
            sin(2*imag_part(x))/(cos(2*imag_part(x)) + cosh(2*real_part(x)))
        """
        GinacFunction.__init__(self, "tanh", latex_name=r"\tanh")
Exemple #16
0
    def __init__(self):
        """
        The arctangent function.

        EXAMPLES::

            sage: arctan(1/2)
            arctan(1/2)
            sage: RDF(arctan(1/2))  # rel tol 1e-15
            0.46364760900080615
            sage: arctan(1 + I)
            arctan(I + 1)
            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

        ``conjugate(arctan(x))==arctan(conjugate(x))``, unless on the branch
        cuts which run along the imaginary axis outside the interval [-I, +I].::

            sage: conjugate(arctan(x))
            conjugate(arctan(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(arctan(y))
            arctan(y)
            sage: conjugate(arctan(y+I))
            conjugate(arctan(y + I))
            sage: conjugate(arctan(1/16))
            arctan(1/16)
            sage: conjugate(arctan(-2*I))
            conjugate(arctan(-2*I))
            sage: conjugate(arctan(2*I))
            conjugate(arctan(2*I))
            sage: conjugate(arctan(I/2))
            arctan(-1/2*I)

        TESTS::

            sage: arctan(x).operator()
            arctan

        Check that :trac:`19918` is fixed::

            sage: arctan(-x).subs(x=oo)
            -1/2*pi
            sage: arctan(-x).subs(x=-oo)
            1/2*pi
        """
        GinacFunction.__init__(self, "arctan", latex_name=r'\arctan',
                conversions=dict(maxima='atan', sympy='atan'))
Exemple #17
0
    def __init__(self):
        r"""
        The hyperbolic cosine function.

        EXAMPLES::

            sage: cosh(pi)
            cosh(pi)
            sage: cosh(3.1415)
            11.5908832931176
            sage: float(cosh(pi))
            11.591953275521519
            sage: RR(cosh(1/2))
            1.12762596520638

            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")
Exemple #18
0
    def __init__(self):
        r"""
        The hyperbolic cotangent function.

        EXAMPLES::

            sage: coth(pi)
            coth(pi)
            sage: coth(0)
            Infinity
            sage: coth(pi*I)
            Infinity
            sage: coth(pi*I/2)
            0
            sage: coth(7*pi*I/2)
            0
            sage: coth(8*pi*I/2)
            Infinity
            sage: coth(7.*pi*I/2)
            -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)
        """
        GinacFunction.__init__(self, "coth", latex_name=r"\operatorname{coth}")
Exemple #19
0
    def __init__(self):
        r"""
        The cotangent function.

        EXAMPLES::

            sage: cot(pi/4)
            1
            sage: RR(cot(pi/4))
            1.00000000000000
            sage: cot(1/2)
            cot(1/2)
            sage: cot(0.5)
            1.83048772171245

            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

        EXAMPLES::

            sage: cot(pi/4)
            1
            sage: cot(x).subs(x==pi/4)
            1
            sage: cot(pi/7)
            cot(1/7*pi)
            sage: cot(x)
            cot(x)

            sage: n(cot(pi/4),100)
            1.0000000000000000000000000000
            sage: float(cot(1))
            0.64209261593433...
            sage: bool(diff(cot(x), x) == diff(1/tan(x), x))
            True
            sage: diff(cot(x), x)
            -cot(x)^2 - 1

        TESTS:

        Test complex input::

            sage: cot(complex(1,1))     # rel tol 1e-15
            (0.21762156185440273-0.8680141428959249j)
            sage: cot(1.+I)
            0.217621561854403 - 0.868014142895925*I
        """
        GinacFunction.__init__(self, "cot", latex_name=r"\cot")
Exemple #20
0
    def __init__(self):
        """
        The cosine function.

        EXAMPLES::

            sage: cos(pi)
            -1
            sage: cos(x).subs(x==pi)
            -1
            sage: cos(2).n(100)
            -0.41614683654714238699756822950
            sage: loads(dumps(cos))
            cos
            sage: cos(x)._sympy_()
            cos(x)

        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

        If possible, the argument is also reduced modulo the
        period length `2\pi`, and well-known identities are
        directly evaluated::

            sage: k = var('k', domain='integer')
            sage: cos(1 + 2*k*pi)
            cos(1)
            sage: cos(k*pi)
            cos(pi*k)
            sage: cos(pi/3 + 2*k*pi)
            1/2

        TESTS::

            sage: conjugate(cos(x))
            cos(conjugate(x))
            sage: cos(complex(1,1))     # rel tol 1e-15
            (0.8337300251311491-0.9888977057628651j)

        Check that :trac:`20752` is fixed::

            sage: cos(3*pi+41/42*pi)
            cos(1/42*pi)
            sage: cos(-5*pi+1/42*pi)
            -cos(1/42*pi)
            sage: cos(pi-1/42*pi)
            -cos(1/42*pi)
        """
        GinacFunction.__init__(self, 'cos', latex_name=r"\cos",
                conversions=dict(maxima='cos',mathematica='Cos',giac='cos'))
Exemple #21
0
    def __init__(self):
        r"""
        The inverse of the hyperbolic sine function.

        EXAMPLES::

            sage: asinh
            arcsinh
            sage: asinh(0.5)
            0.481211825059603
            sage: asinh(1/2)
            arcsinh(1/2)
            sage: asinh(1 + I*1.0)
            1.06127506190504 + 0.666239432492515*I

        To prevent automatic evaluation use the ``hold`` argument::

            sage: asinh(-2,hold=True)
            arcsinh(-2)

        To then evaluate again, use the ``unhold`` method::

            sage: asinh(-2,hold=True).unhold()
            -arcsinh(2)

        ``conjugate(asinh(x))==asinh(conjugate(x))`` unless on the branch
        cuts which run along the imaginary axis outside the interval [-I, +I].::

            sage: conjugate(asinh(x))
            conjugate(arcsinh(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(asinh(y))
            arcsinh(y)
            sage: conjugate(asinh(y+I))
            conjugate(arcsinh(y + I))
            sage: conjugate(asinh(1/16))
            arcsinh(1/16)
            sage: conjugate(asinh(I/2))
            arcsinh(-1/2*I)
            sage: conjugate(asinh(2*I))
            conjugate(arcsinh(2*I))

        TESTS::

            sage: asinh(x).operator()
            arcsinh
            sage: latex(asinh(x))
            \operatorname{arsinh}\left(x\right)
            sage: asinh(x)._sympy_()
            asinh(x)
        """
        GinacFunction.__init__(self, "arcsinh",
                latex_name=r"\operatorname{arsinh}",
                conversions=dict(maxima='asinh', sympy='asinh', fricas='asinh',
                                giac='asinh'))
Exemple #22
0
    def __init__(self):
        r"""
        The polylog function
        `\text{Li}_n(z) = \sum_{k=1}^{\infty} z^k / k^n`.

        INPUT:

        -  ``n`` - object
        -  ``z`` - object

        EXAMPLES::

            sage: polylog(1, x)
            -log(-x + 1)
            sage: polylog(2,1)
            1/6*pi^2
            sage: polylog(2,x^2+1)
            polylog(2, x^2 + 1)
            sage: polylog(4,0.5)
            polylog(4, 0.500000000000000)

            sage: f = polylog(4, 1); f
            1/90*pi^4
            sage: f.n()
            1.08232323371114

            sage: polylog(4, 2).n()
            2.42786280675470 - 0.174371300025453*I
            sage: complex(polylog(4,2))
            (2.4278628067547032-0.17437130002545306j)
            sage: float(polylog(4,0.5))
            0.5174790616738993

            sage: z = var('z')
            sage: polylog(2,z).series(z==0, 5)
            1*z + 1/4*z^2 + 1/9*z^3 + 1/16*z^4 + Order(z^5)

            sage: loads(dumps(polylog))
            polylog

            sage: latex(polylog(5, x))
            {\rm Li}_{5}(x)

        TESTS:

        Check if #8459 is fixed::

            sage: t = maxima(polylog(5,x)).sage(); t
            polylog(5, x)
            sage: t.operator() == polylog
            True
            sage: t.subs(x=.5).n()
            0.508400579242269
        """
        GinacFunction.__init__(self, "polylog", nargs=2)
Exemple #23
0
    def __init__(self):
        """
        The tangent function.

        EXAMPLES::

            sage: tan(pi)
            0
            sage: tan(3.1415)
            -0.0000926535900581913
            sage: tan(3.1415/4)
            0.999953674278156
            sage: tan(pi/4)
            1
            sage: tan(1/2)
            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

        If possible, the argument is also reduced modulo the
        period length `\pi`, and well-known identities are
        directly evaluated::

            sage: k = var('k', domain='integer')
            sage: tan(1 + 2*k*pi)
            tan(1)
            sage: tan(k*pi)
            0

        TESTS::

            sage: tan(x)._sympy_()
            tan(x)
            sage: conjugate(tan(x))
            tan(conjugate(x))
            sage: tan(complex(1,1))     # rel tol 1e-15
            (0.2717525853195118+1.0839233273386946j)

        Check that :trac:`19791` is fixed::

            sage: tan(2+I).imag().n()
            1.16673625724092
        """
        GinacFunction.__init__(self, 'tan', latex_name=r"\tan")
Exemple #24
0
    def __init__(self):
        """
        The arccosine function.

        EXAMPLES::

            sage: arccos(0.5)
            1.04719755119660
            sage: arccos(1/2)
            1/3*pi
            sage: arccos(1 + 1.0*I)
            0.904556894302381 - 1.06127506190504*I
            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

        ``conjugate(arccos(x))==arccos(conjugate(x))``, unless on the branch
        cuts, which run along the real axis outside the interval [-1, +1].::

            sage: conjugate(arccos(x))
            conjugate(arccos(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(arccos(y))
            conjugate(arccos(y))
            sage: conjugate(arccos(y+I))
            conjugate(arccos(y + I))
            sage: conjugate(arccos(1/16))
            arccos(1/16)
            sage: conjugate(arccos(2))
            conjugate(arccos(2))
            sage: conjugate(arccos(-2))
            pi - conjugate(arccos(2))

        TESTS::

            sage: arccos(x)._sympy_()
            acos(x)
            sage: arccos(x).operator()
            arccos
            sage: acos(complex(1,1))
            (0.9045568943023814-1.0612750619050357j)
        """
        GinacFunction.__init__(self, 'arccos', latex_name=r"\arccos",
                conversions=dict(maxima='acos', sympy='acos'))
Exemple #25
0
    def __init__(self):
        """
        TESTS::

            sage: from sage.functions.log import logb
            sage: loads(dumps(logb))
            log
        """
        GinacFunction.__init__(self, 'log', ginac_name='logb', nargs=2,
                            latex_name=r'\log',
                            conversions=dict(maxima='log'))
Exemple #26
0
    def __init__(self):
        """
        TESTS::

            sage: loads(dumps(exp))
            exp
            sage: maxima(exp(x))._sage_()
            e^x
        """
        GinacFunction.__init__(self, "exp", latex_name=r"\exp",
                                   conversions=dict(maxima='exp', fricas='exp'))
Exemple #27
0
    def __init__(self):
        r"""
        The inverse of the hyperbolic tangent function.

        EXAMPLES::

            sage: atanh(0.5)
            0.549306144334055
            sage: atanh(1/2)
            1/2*log(3)
            sage: atanh(1 + I*1.0)
            0.402359478108525 + 1.01722196789785*I

        To prevent automatic evaluation use the ``hold`` argument::

            sage: atanh(-1/2,hold=True)
            arctanh(-1/2)

        To then evaluate again, use the ``unhold`` method::

            sage: atanh(-1/2,hold=True).unhold()
            -1/2*log(3)

        ``conjugate(arctanh(x))==arctanh(conjugate(x))`` unless on the branch
        cuts which run along the real axis outside the interval [-1, +1].::

            sage: conjugate(atanh(x))
            conjugate(arctanh(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(atanh(y))
            conjugate(arctanh(y))
            sage: conjugate(atanh(y+I))
            conjugate(arctanh(y + I))
            sage: conjugate(atanh(1/16))
            1/2*log(17/15)
            sage: conjugate(atanh(I/2))
            arctanh(-1/2*I)
            sage: conjugate(atanh(-2*I))
            arctanh(2*I)

        TESTS::

            sage: atanh(x).operator()
            arctanh
            sage: latex(atanh(x))
            \operatorname{artanh}\left(x\right)
            sage: atanh(x)._sympy_()
            atanh(x)
        """
        GinacFunction.__init__(self, "arctanh",
                latex_name=r"\operatorname{artanh}",
                conversions=dict(maxima='atanh', sympy='atanh', fricas='atanh',
                                giac='atanh'))
Exemple #28
0
    def __init__(self):
        r"""
        Riemann zeta function at s with s a real or complex number.

        INPUT:

        -  ``s`` - real or complex number

        If s is a real number the computation is done using the MPFR
        library. When the input is not real, the computation is done using
        the PARI C library.

        EXAMPLES::

            sage: zeta(x)
            zeta(x)
            sage: zeta(2)
            1/6*pi^2
            sage: zeta(2.)
            1.64493406684823
            sage: RR = RealField(200)
            sage: zeta(RR(2))
            1.6449340668482264364724151666460251892189499012067984377356
            sage: zeta(I)
            zeta(I)
            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))
            \zeta(x)
            sage: a = loads(dumps(zeta(x)))
            sage: a.operator() == zeta
            True

            sage: zeta(1)
            Infinity
            sage: zeta(x).subs(x=1)
            Infinity
        """
        GinacFunction.__init__(self, "zeta")
Exemple #29
0
    def __init__(self):
        r"""
        The cosecant function.

        EXAMPLES::

            sage: csc(pi/4)
            sqrt(2)
            sage: csc(x).subs(x==pi/4)
            sqrt(2)
            sage: csc(pi/7)
            csc(1/7*pi)
            sage: csc(x)
            csc(x)
            sage: RR(csc(pi/4))
            1.41421356237310
            sage: n(csc(pi/4),100)
            1.4142135623730950488016887242
            sage: float(csc(pi/4))
            1.4142135623730951
            sage: csc(1/2)
            csc(1/2)
            sage: csc(0.5)
            2.08582964293349

            sage: bool(diff(csc(x), x) == diff(1/sin(x), x))
            True
            sage: diff(csc(x), x)
            -cot(x)*csc(x)
            sage: latex(csc(x))
            \csc\left(x\right)
            sage: csc(x)._sympy_()
            csc(x)

        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)

        TESTS:

        Test complex input::

            sage: csc(complex(1,1))     # rel tol 1e-15
            (0.6215180171704284-0.30393100162842646j)
        """
        GinacFunction.__init__(self, 'csc', latex_name=r"\csc")
Exemple #30
0
    def __init__(self):
        r"""
        The dilogarithm function
        `\text{Li}_2(z) = \sum_{k=1}^{\infty} z^k / k^2`.

        This is simply an alias for polylog(2, z).

        EXAMPLES::

            sage: dilog(1)
            1/6*pi^2
            sage: dilog(1/2)
            1/12*pi^2 - 1/2*log(2)^2
            sage: dilog(x^2+1)
            dilog(x^2 + 1)
            sage: dilog(-1)
            -1/12*pi^2
            sage: dilog(-1.1)
            -0.890838090262283
            sage: float(dilog(1))
            1.6449340668482262
            sage: var('z')
            z
            sage: dilog(z).diff(z, 2)
            log(-z + 1)/z^2 - 1/((z - 1)*z)
            sage: dilog(z).series(z==1/2, 3)
            (1/12*pi^2 - 1/2*log(2)^2) + (-2*log(1/2))*(z - 1/2) + (2*log(1/2) + 2)*(z - 1/2)^2 + Order(1/8*(2*z - 1)^3)

            sage: latex(dilog(z))
            {\rm Li}_2\left(z\right)

        TESTS:

        ``conjugate(dilog(x))==dilog(conjugate(x))`` unless on the branch cuts
        which run along the positive real axis beginning at 1.::

            sage: conjugate(dilog(x))
            conjugate(dilog(x))
            sage: var('y',domain='positive')
            y
            sage: conjugate(dilog(y))
            conjugate(dilog(y))
            sage: conjugate(dilog(1/19))
            dilog(1/19)
            sage: conjugate(dilog(1/2*I))
            dilog(-1/2*I)
            sage: dilog(conjugate(1/2*I))
            dilog(-1/2*I)
            sage: conjugate(dilog(2))
            conjugate(dilog(2))
        """
        GinacFunction.__init__(self, 'dilog',
                conversions=dict(maxima='li[2]'))
Exemple #31
0
    def __init__(self):
        r"""
        The cosecant function.

        EXAMPLES::

            sage: csc(pi/4)
            sqrt(2)
            sage: csc(x).subs(x==pi/4)
            sqrt(2)
            sage: csc(pi/7)
            csc(1/7*pi)
            sage: csc(x)
            csc(x)
            sage: RR(csc(pi/4))
            1.41421356237310
            sage: n(csc(pi/4),100)
            1.4142135623730950488016887242
            sage: float(csc(pi/4))
            1.4142135623730951
            sage: csc(1/2)
            csc(1/2)
            sage: csc(0.5)
            2.08582964293349

            sage: bool(diff(csc(x), x) == diff(1/sin(x), x))
            True
            sage: diff(csc(x), x)
            -cot(x)*csc(x)
            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)

        TESTS:

        Test complex input::

            sage: csc(complex(1,1))     # rel tol 1e-15
            (0.6215180171704284-0.30393100162842646j)
        """
        GinacFunction.__init__(self, "csc", latex_name=r"\csc")
Exemple #32
0
    def __init__(self):
        """
        The arcsine function.

        EXAMPLES::

            sage: arcsin(0.5)
            0.523598775598299
            sage: arcsin(1/2)
            1/6*pi
            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

        ``conjugate(arcsin(x))==arcsin(conjugate(x))``, unless on the branch
        cuts which run along the real axis outside the interval [-1, +1].::

            sage: conjugate(arcsin(x))
            conjugate(arcsin(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(arcsin(y))
            conjugate(arcsin(y))
            sage: conjugate(arcsin(y+I))
            conjugate(arcsin(y + I))
            sage: conjugate(arcsin(1/16))
            arcsin(1/16)
            sage: conjugate(arcsin(2))
            conjugate(arcsin(2))
            sage: conjugate(arcsin(-2))
            -conjugate(arcsin(2))

        TESTS::

            sage: arcsin(x).operator()
            arcsin
        """
        GinacFunction.__init__(self,
                               'arcsin',
                               latex_name=r"\arcsin",
                               conversions=dict(maxima='asin', sympy='asin'))
Exemple #33
0
    def __init__(self):
        """
        The arccotangent function.

        EXAMPLES::

            sage: arccot(1/2)
            arccot(1/2)
            sage: RDF(arccot(1/2))  # abs tol 2e-16
            1.1071487177940906
            sage: arccot(1 + I)
            arccot(I + 1)
            sage: arccot(1/2).n(100)
            1.1071487177940905030170654602
            sage: float(arccot(1/2))  # abs tol 2e-16
            1.1071487177940906
            sage: bool(diff(acot(x), x) == -diff(atan(x), x))
            True
            sage: diff(acot(x), x)
            -1/(x^2 + 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

        TESTS:

        Test complex input::

            sage: arccot(x)._sympy_()
            acot(x)
            sage: arccot(complex(1,1))  # rel tol 1e-15
            (0.5535743588970452-0.4023594781085251j)
            sage: arccot(1.+I)
            0.553574358897045 - 0.402359478108525*I

        """
        GinacFunction.__init__(self,
                               'arccot',
                               latex_name=r"\operatorname{arccot}",
                               conversions=dict(maxima='acot',
                                                sympy='acot',
                                                fricas='acot',
                                                giac='acot'))
Exemple #34
0
    def __init__(self):
        r"""
        The inverse of the hyperbolic tangent function.

        EXAMPLES::

            sage: arctanh(0.5)
            0.549306144334055
            sage: arctanh(1/2)
            arctanh(1/2)
            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)

        ``conjugate(arctanh(x))==arctanh(conjugate(x))`` unless on the branch
        cuts which run along the real axis outside the interval [-1, +1].::

            sage: conjugate(arctanh(x))
            conjugate(arctanh(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(arctanh(y))
            conjugate(arctanh(y))
            sage: conjugate(arctanh(y+I))
            conjugate(arctanh(y + I))
            sage: conjugate(arctanh(1/16))
            arctanh(1/16)
            sage: conjugate(arctanh(I/2))
            arctanh(-1/2*I)
            sage: conjugate(arctanh(-2*I))
            arctanh(2*I)

        TESTS::

            sage: arctanh(x).operator()
            arctanh
            sage: latex(arctanh(x))
            {\rm arctanh}\left(x\right)
        """
        GinacFunction.__init__(self, "arctanh", latex_name=r"{\rm arctanh}",
                conversions=dict(maxima='atanh', sympy='atanh'))
Exemple #35
0
    def __init__(self):
        """
        The arccosine function.

        EXAMPLES::

            sage: arccos(0.5)
            1.04719755119660
            sage: arccos(1/2)
            1/3*pi
            sage: arccos(1 + 1.0*I)
            0.904556894302381 - 1.06127506190504*I
            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

        ``conjugate(arccos(x))==arccos(conjugate(x))``, unless on the branch
        cuts, which run along the real axis outside the interval [-1, +1].::

            sage: conjugate(arccos(x))
            conjugate(arccos(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(arccos(y))
            conjugate(arccos(y))
            sage: conjugate(arccos(y+I))
            conjugate(arccos(y + I))
            sage: conjugate(arccos(1/16))
            arccos(1/16)
            sage: conjugate(arccos(2))
            conjugate(arccos(2))
            sage: conjugate(arccos(-2))
            pi - conjugate(arccos(2))

        TESTS::

            sage: arccos(x).operator()
            arccos
        """
        GinacFunction.__init__(self, 'arccos', latex_name=r"\arccos",
                conversions=dict(maxima='acos', sympy='acos'))
Exemple #36
0
    def __init__(self):
        r"""
        The secant function.

        EXAMPLES::

            sage: sec(pi/4)
            sqrt(2)
            sage: sec(x).subs(x==pi/4)
            sqrt(2)
            sage: sec(pi/7)
            sec(1/7*pi)
            sage: sec(x)
            sec(x)
            sage: RR(sec(pi/4))
            1.41421356237310
            sage: n(sec(pi/4),100)
            1.4142135623730950488016887242
            sage: float(sec(pi/4))
            1.4142135623730951
            sage: sec(1/2)
            sec(1/2)
            sage: sec(0.5)
            1.13949392732455

            sage: bool(diff(sec(x), x) == diff(1/cos(x), x))
            True
            sage: diff(sec(x), x)
            sec(x)*tan(x)
            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)

        TESTS:

        Test complex input::

            sage: sec(complex(1,1))     # rel tol 1e-15
            (0.49833703055518686+0.5910838417210451j)
        """
        GinacFunction.__init__(self, "sec", latex_name=r"\sec")
Exemple #37
0
    def __init__(self):
        r"""
        The digamma function, `\psi(x)`, is the logarithmic derivative of the
        gamma function.

        .. MATH::

            \psi(x) = \frac{d}{dx} \log(\Gamma(x)) = \frac{\Gamma'(x)}{\Gamma(x)}

        EXAMPLES::

            sage: from sage.functions.gamma import psi1
            sage: psi1(x)
            psi(x)
            sage: psi1(x).derivative(x)
            psi(1, x)

        ::

            sage: psi1(3)
            -euler_gamma + 3/2

        ::

            sage: psi(.5)
            -1.96351002602142
            sage: psi(RealField(100)(.5))
            -1.9635100260214234794409763330

        TESTS::

            sage: latex(psi1(x))
            \psi\left(x\right)
            sage: loads(dumps(psi1(x)+1))
            psi(x) + 1

            sage: t = psi1(x); t
            psi(x)
            sage: t.subs(x=.2)
            -5.28903989659219
            sage: psi(x)._sympy_()
            polygamma(0, x)
        """
        GinacFunction.__init__(self,
                               "psi",
                               nargs=1,
                               latex_name=r'\psi',
                               conversions=dict(mathematica='PolyGamma',
                                                maxima='psi[0]',
                                                sympy='digamma'))
Exemple #38
0
Fichier : log.py Projet : yarv/sage
    def __init__(self):
        """
        TESTS::

            sage: from sage.functions.log import logb
            sage: loads(dumps(logb))
            log
        """
        GinacFunction.__init__(self,
                               'log',
                               ginac_name='logb',
                               nargs=2,
                               latex_name=r'\log',
                               conversions=dict(maxima='log'))
Exemple #39
0
    def __init__(self):
        r"""
        Stieltjes constant of index ``n``.

        ``stieltjes(0)`` is identical to the Euler-Mascheroni constant
        (:class:`sage.symbolic.constants.EulerGamma`). The Stieltjes
        constants are used in the series expansions of `\zeta(s)`.

        INPUT:

        -  ``n`` - non-negative integer

        EXAMPLES::

            sage: _ = var('n')
            sage: stieltjes(n)
            stieltjes(n)
            sage: stieltjes(0)
            euler_gamma
            sage: stieltjes(2)
            stieltjes(2)
            sage: stieltjes(int(2))
            stieltjes(2)
            sage: stieltjes(2).n(100)
            -0.0096903631928723184845303860352
            sage: RR = RealField(200)
            sage: stieltjes(RR(2))
            -0.0096903631928723184845303860352125293590658061013407498807014

        It is possible to use the ``hold`` argument to prevent
        automatic evaluation::

            sage: stieltjes(0,hold=True)
            stieltjes(0)

            sage: latex(stieltjes(n))
            \gamma_{n}
            sage: a = loads(dumps(stieltjes(n)))
            sage: a.operator() == stieltjes
            True
            sage: stieltjes(x)._sympy_()
            stieltjes(x)

            sage: stieltjes(x).subs(x==0)
            euler_gamma
        """
        GinacFunction.__init__(self, "stieltjes", nargs=1,
                            conversions=dict(mathematica='StieltjesGamma',
                                sympy='stieltjes'),
                            latex_name=r'\gamma')
Exemple #40
0
    def __init__(self):
        """
        The cosine function.

        EXAMPLES::

            sage: cos(pi)
            -1
            sage: cos(x).subs(x==pi)
            -1
            sage: cos(2).n(100)
            -0.41614683654714238699756822950
            sage: loads(dumps(cos))
            cos
            sage: cos(x)._sympy_()
            cos(x)

        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

        TESTS::

            sage: conjugate(cos(x))
            cos(conjugate(x))
            sage: cos(complex(1,1))     # rel tol 1e-15
            (0.8337300251311491-0.9888977057628651j)

        Check that :trac:`20752` is fixed::

            sage: cos(3*pi+41/42*pi)
            cos(1/42*pi)
            sage: cos(-5*pi+1/42*pi)
            -cos(1/42*pi)
            sage: cos(pi-1/42*pi)
            -cos(1/42*pi)
        """
        GinacFunction.__init__(self,
                               'cos',
                               latex_name=r"\cos",
                               conversions=dict(maxima='cos',
                                                mathematica='Cos'))
Exemple #41
0
Fichier : log.py Projet : yarv/sage
    def __init__(self):
        """
        TESTS::

            sage: loads(dumps(ln))
            log
            sage: maxima(ln(x))._sage_()
            log(x)
        """
        GinacFunction.__init__(self,
                               'log',
                               latex_name=r'\log',
                               conversions=dict(maxima='log',
                                                fricas='log',
                                                mathematica='Log'))
Exemple #42
0
    def __init__(self):
        """
        The arcsecant function.

        EXAMPLES::

            sage: arcsec(2)
            arcsec(2)
            sage: arcsec(2.0)
            1.04719755119660
            sage: arcsec(2).n(100)
            1.0471975511965977461542144611
            sage: arcsec(1/2).n(100)
            1.3169578969248167086250463473*I
            sage: RDF(arcsec(2))  # abs tol 1e-15
            1.0471975511965976
            sage: arcsec(1 + I)
            arcsec(I + 1)
            sage: diff(asec(x), x)
            1/(sqrt(x^2 - 1)*x)
            sage: arcsec(x)._sympy_()
            asec(x)

        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

        TESTS:

        Test complex input::

            sage: arcsec(complex(1,1))  # rel tol 1e-15
            (1.118517879643706+0.5306375309525178j)
        """
        GinacFunction.__init__(self,
                               'arcsec',
                               latex_name=r"\operatorname{arcsec}",
                               conversions=dict(maxima='asec',
                                                sympy='asec',
                                                fricas='asec',
                                                giac='asec'))
Exemple #43
0
    def __init__(self):
        r"""
        Derivatives of the digamma function `\psi(x)`. T

        EXAMPLES::

            sage: from sage.functions.other import psi2
            sage: psi2(2, x)
            psi(2, x)
            sage: psi2(2, x).derivative(x)
            psi(3, x)
            sage: n = var('n')
            sage: psi2(n, x).derivative(x)
            psi(n + 1, x)

        ::

            sage: psi2(0, x)
            psi(x)
            sage: psi2(-1, x)
            log(gamma(x))
            sage: psi2(3, 1)
            1/15*pi^4

        ::

            sage: psi2(2, .5).n()
            -16.8287966442343
            sage: psi2(2, .5).n(100)
            -16.828796644234319995596334261

        Tests::

            sage: psi2(n, x).derivative(n)
            Traceback (most recent call last):
            ...
            RuntimeError: cannot diff psi(n,x) with respect to n

            sage: latex(psi2(2,x))
            \psi\left(2, x\right)
            sage: loads(dumps(psi2(2,x)+1))
            psi(2, x) + 1
        """
        GinacFunction.__init__(self,
                               "psi",
                               nargs=2,
                               latex_name='\psi',
                               conversions=dict(mathematica='PolyGamma'))
Exemple #44
0
    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
            sage: real(z)
            1
            sage: real(5/3)
            5/3
            sage: a = 2.5
            sage: real(a)
            2.50000000000000
            sage: type(real(a))
            <type 'sage.rings.real_mpfr.RealLiteral'>
            sage: real(1.0r)
            1.0

        TESTS::

            sage: loads(dumps(real_part))
            real_part

        Check if #6401 is fixed::

            sage: latex(x.real())
            \Re \left( x \right)

            sage: f(x) = function('f',x)
            sage: latex( f(x).real())
            \Re \left( f\left(x\right) \right)
        """
        GinacFunction.__init__(self,
                               "real_part",
                               conversions=dict(maxima='realpart'))
Exemple #45
0
    def __init__(self):
        r"""
        The inverse of the hyperbolic cotangent function.

        EXAMPLES::

            sage: arccoth(2.0)
            0.549306144334055
            sage: arccoth(2)
            arccoth(2)
            sage: arccoth(1 + I*1.0)
            0.402359478108525 - 0.553574358897045*I
            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``::

            sage: float(arccoth(2))  # abs tol 1e-16
            0.5493061443340548
            sage: float(arccoth(2).n(53))   # Correct result to 53 bits
            0.5493061443340549
            sage: float(arccoth(2).n(100))  # Compute 100 bits and then round to 53
            0.5493061443340549

        TESTS::

            sage: latex(arccoth(x))
            \operatorname{arccoth}\left(x\right)
            sage: acoth(x)._sympy_()
            acoth(x)

        Check if :trac:`23636` is fixed::

            sage: arccoth(float(1.1))
            1.5222612188617113
        """
        GinacFunction.__init__(self,
                               "arccoth",
                               latex_name=r"\operatorname{arccoth}",
                               conversions=dict(maxima='acoth',
                                                sympy='acoth',
                                                fricas='acoth'))
Exemple #46
0
    def __init__(self):
        """
        The arccosecant function.

        EXAMPLES::

            sage: arccsc(2)
            arccsc(2)
            sage: RDF(arccsc(2))  # rel tol 1e-15
            0.5235987755982988
            sage: arccsc(2).n(100)
            0.52359877559829887307710723055
            sage: float(arccsc(2))
            0.52359877559829...
            sage: arccsc(1 + I)
            arccsc(I + 1)
            sage: diff(acsc(x), x)
            -1/(sqrt(x^2 - 1)*x)
            sage: arccsc(x)._sympy_()
            acsc(x)

        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

        TESTS:

        Test complex input::

            sage: arccsc(complex(1,1))  # rel tol 1e-15
            (0.45227844715119064-0.5306375309525178j)
        """
        GinacFunction.__init__(self,
                               'arccsc',
                               latex_name=r"\operatorname{arccsc}",
                               conversions=dict(maxima='acsc',
                                                sympy='acsc',
                                                fricas='acsc',
                                                giac='acsc'))
Exemple #47
0
    def __init__(self):
        r"""
        The hyperbolic tangent function.

        EXAMPLES::

            sage: tanh(pi)
            tanh(pi)
            sage: tanh(3.1415)
            0.996271386633702
            sage: float(tanh(pi))
            0.99627207622075
            sage: tan(3.1415/4)
            0.999953674278156
            sage: tanh(pi/4)
            tanh(1/4*pi)
            sage: RR(tanh(1/2))
            0.462117157260010

        ::

            sage: CC(tanh(pi + I*e))
            0.997524731976164 - 0.00279068768100315*I
            sage: ComplexField(100)(tanh(pi + I*e))
            0.99752473197616361034204366446 - 0.0027906876810031453884245163923*I
            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))
            \tanh\left(x\right)
        """
        GinacFunction.__init__(self, "tanh", latex_name=r"\tanh")
Exemple #48
0
    def __init__(self):
        """
        The tangent function.

        EXAMPLES::

            sage: tan(pi)
            0
            sage: tan(3.1415)
            -0.0000926535900581913
            sage: tan(3.1415/4)
            0.999953674278156
            sage: tan(pi/4)
            1
            sage: tan(1/2)
            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

        TESTS::

            sage: tan(x)._sympy_()
            tan(x)
            sage: conjugate(tan(x))
            tan(conjugate(x))
            sage: tan(complex(1,1))     # rel tol 1e-15
            (0.2717525853195118+1.0839233273386946j)

        Check that :trac:`19791` is fixed::

            sage: tan(2+I).imag().n()
            1.16673625724092
        """
        GinacFunction.__init__(self, 'tan', latex_name=r"\tan")
Exemple #49
0
    def __init__(self):
        r"""
        The hyperbolic secant function.

        EXAMPLES::

            sage: sech(pi)
            sech(pi)
            sage: sech(3.1415)
            0.0862747018248192
            sage: float(sech(pi))
            0.0862667383340544...
            sage: RR(sech(pi))
            0.0862667383340544
            sage: sech(0)
            1
            sage: sech(pi*I)
            -1
            sage: sech(pi*I/2)
            Infinity
            sage: sech(7*pi*I/2)
            Infinity
            sage: sech(8*pi*I/2)
            1
            sage: sech(8.*pi*I/2)
            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)
            sage: sech(x)._sympy_()
            sech(x)
        """
        GinacFunction.__init__(
            self,
            "sech",
            latex_name=r"\operatorname{sech}",
        )
Exemple #50
0
    def __init__(self):
        r"""
        The digamma function, `\psi(x)`, is the logarithmic derivative of the
        gamma function.

        `\psi(x) = \frac{d}{dx} \log(\Gamma(x)) = \frac{\Gamma'(x)}{\Gamma(x)}`

        EXAMPLES::

            sage: from sage.functions.other import psi1
            sage: psi1(x)
            psi(x)
            sage: psi1(x).derivative(x)
            psi(1, x)

        ::

            sage: psi1(3)
            -euler_gamma + 3/2

        ::

            sage: psi(.5)
            -1.96351002602142
            sage: psi(RealField(100)(.5))
            -1.9635100260214234794409763330
            
        Tests::

            sage: latex(psi1(x))
            \psi\left(x\right)
            sage: loads(dumps(psi1(x)+1))
            psi(x) + 1
        """
        GinacFunction.__init__(self,
                               "psi",
                               nargs=1,
                               latex_name='\psi',
                               conversions=dict(maxima='psi[0]',
                                                mathematica='PolyGamma'))
Exemple #51
0
    def __init__(self):
        """
        The sine function.

        EXAMPLES::

            sage: sin(0)
            0
            sage: sin(x).subs(x==0)
            0
            sage: sin(2).n(100)
            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

        TESTS::

            sage: conjugate(sin(x))
            sin(conjugate(x))
            sage: sin(complex(1,1))     # rel tol 1e-15
            (1.2984575814159773+0.6349639147847361j)

        """
        GinacFunction.__init__(self,
                               "sin",
                               latex_name=r"\sin",
                               conversions=dict(maxima='sin',
                                                mathematica='Sin'))
Exemple #52
0
    def __init__(self):
        r"""
        The hyperbolic cotangent function.

        EXAMPLES::

            sage: coth(pi)
            coth(pi)
            sage: coth(0)
            Infinity
            sage: coth(pi*I)
            Infinity
            sage: coth(pi*I/2)
            0
            sage: coth(7*pi*I/2)
            0
            sage: coth(8*pi*I/2)
            Infinity
            sage: coth(7.*pi*I/2)
            -I*cot(3.50000000000000*pi)
            sage: coth(3.1415)
            1.00374256795520
            sage: float(coth(pi))
            1.0037418731973213
            sage: RR(coth(pi))
            1.00374187319732
            sage: coth(complex(1, 2))  # abs tol 1e-15
            (0.8213297974938518+0.17138361290918508j)

            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))
            \coth\left(x\right)
            sage: coth(x)._sympy_()
            coth(x)
        """
        GinacFunction.__init__(self, "coth", latex_name=r"\coth")
Exemple #53
0
    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
            sage: imaginary(z)
            2
            sage: imag(z)
            2
            sage: loads(dumps(imag_part))
            imag_part

        Check if #6401 is fixed::

            sage: latex(x.imag())
            \Im \left( x \right)

            sage: f(x) = function('f',x)
            sage: latex( f(x).imag())
            \Im \left( f\left(x\right) \right)
        """
        GinacFunction.__init__(self,
                               "imag_part",
                               conversions=dict(maxima='imagpart'))
Exemple #54
0
    def __init__(self):
        r"""
        The inverse of the hyperbolic cosecant function.

        EXAMPLES::

            sage: acsch(2.0)
            0.481211825059603
            sage: acsch(2)
            arccsch(2)
            sage: acsch(1 + I*1.0)
            0.530637530952518 - 0.452278447151191*I
            sage: acsch(1).n(200)
            0.88137358701954302523260932497979230902816032826163541075330
            sage: float(acsch(1))
            0.881373587019543

            sage: diff(acsch(x), x)
            -1/(sqrt(x^2 + 1)*x)
            sage: latex(acsch(x))
            \operatorname{arcsch}\left(x\right)

        TESTS:

        Check if :trac:`20818` is fixed::

            sage: acsch(float(0.1))
            2.99822295029797
            sage: acsch(x)._sympy_()
            acsch(x)
        """
        GinacFunction.__init__(self,
                               "arccsch",
                               latex_name=r"\operatorname{arcsch}",
                               conversions=dict(maxima='acsch',
                                                sympy='acsch',
                                                fricas='acsch'))
Exemple #55
0
    def __init__(self):
        """
        The cosine function.

        EXAMPLES::

            sage: cos(pi)
            -1
            sage: cos(x).subs(x==pi)
            -1
            sage: cos(2).n(100)
            -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

        TESTS::

            sage: conjugate(cos(x))
            cos(conjugate(x))
        """
        GinacFunction.__init__(self,
                               "cos",
                               latex_name=r"\cos",
                               conversions=dict(maxima='cos',
                                                mathematica='Cos'))
Exemple #56
0
    def __init__(self):
        r"""
        Derivatives of the Riemann zeta function.

        EXAMPLES::

            sage: zetaderiv(1, x)
            zetaderiv(1, x)
            sage: zetaderiv(1, x).diff(x)
            zetaderiv(2, x)
            sage: var('n')
            n
            sage: zetaderiv(n,x)
            zetaderiv(n, x)

        TESTS::

            sage: latex(zetaderiv(2,x))
            \zeta^\prime\left(2, x\right)
            sage: a = loads(dumps(zetaderiv(2,x)))
            sage: a.operator() == zetaderiv
            True
        """
        GinacFunction.__init__(self, "zetaderiv", nargs=2)
Exemple #57
0
    def __init__(self):
        """
        The tangent function.

        EXAMPLES::

            sage: tan(pi)
            0
            sage: tan(3.1415)
            -0.0000926535900581913
            sage: tan(3.1415/4)
            0.999953674278156
            sage: tan(pi/4)
            1
            sage: tan(1/2)
            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

        TESTS::

            sage: conjugate(tan(x))
            tan(conjugate(x))
        """
        GinacFunction.__init__(self, "tan", latex_name=r"\tan")
Exemple #58
0
    def __init__(self):
        r"""
        The modified arctangent function.

        Returns the arc tangent (measured in radians) of `y/x`, where
        unlike ``arctan(y/x)``, the signs of both ``x`` and ``y`` are
        considered.  In particular, this function measures the angle
        of a ray through the origin and `(x,y)`, with the positive
        `x`-axis the zero mark, and with output angle `\theta`
        being between `-\pi<\theta<=\pi`.

        Hence, ``arctan2(y,x) = arctan(y/x)`` only for `x>0`.  One
        may consider the usual arctan to measure angles of lines
        through the origin, while the modified function measures
        rays through the origin.

        Note that the `y`-coordinate is by convention the first input.


        EXAMPLES:

        Note the difference between the two functions::

            sage: arctan2(1,-1)
            3/4*pi
            sage: arctan(1/-1)
            -1/4*pi

        This is consistent with Python and Maxima::

            sage: maxima.atan2(1,-1)
            (3*%pi)/4
            sage: math.atan2(1,-1)
            2.356194490192345

        More examples::

            sage: arctan2(1,0)
            1/2*pi
            sage: arctan2(2,3)
            arctan(2/3)
            sage: arctan2(-1,-1)
            -3/4*pi

        Of course we can approximate as well::

            sage: arctan2(-1/2,1).n(100)
            -0.46364760900080611621425623146
            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: a = numpy.linspace(1, 3, 3)
            sage: b = numpy.linspace(3, 6, 3)
            sage: atan2(a, b)
            array([ 0.32175055,  0.41822433,  0.46364761])

            sage: atan2(1,a)
            array([ 0.78539816,  0.46364761,  0.32175055])

            sage: atan2(a, 1)
            array([ 0.78539816,  1.10714872,  1.24904577])

        TESTS::

            sage: x,y = var('x,y')
            sage: arctan2(y,x).operator()
            arctan2

        Check if :trac:`8565` is fixed::

            sage: atan2(-pi,0)
            -1/2*pi

        Check if :trac:`8564` is fixed::

            sage: arctan2(x,x)._sympy_()
            atan2(x, x)

        Check if numerical evaluation works :trac:`9913`::

            sage: arctan2(0, -log(2)).n()
            3.14159265358979

        Check that atan2(0,0) returns NaN :trac:`21614`::

            sage: atan2(0,0)
            NaN
            sage: atan2(0,0).n()
            NaN
            sage: atan2(0,0,hold=True)
            arctan2(0, 0)
            sage: atan2(0,0,hold=True).n()
            Traceback (most recent call last):
            ...
            RuntimeError: atan2(): division by zero

        Check if :trac:`10062` is fixed, this was caused by
        ``(I*I).is_positive()`` returning ``True``::

            sage: arctan2(0, I*I)
            pi
        """
        GinacFunction.__init__(self,
                               'arctan2',
                               nargs=2,
                               latex_name=r"\arctan",
                               conversions=dict(maxima='atan2', sympy='atan2'))
Exemple #59
0
    def __init__(self):
        r"""
        The sine function.

        EXAMPLES::

            sage: sin(0)
            0
            sage: sin(x).subs(x==0)
            0
            sage: sin(2).n(100)
            0.90929742682568169539601986591
            sage: loads(dumps(sin))
            sin
            sage: sin(x)._sympy_()
            sin(x)

        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

        If possible, the argument is also reduced modulo the
        period length `2\pi`, and well-known identities are
        directly evaluated::

            sage: k = var('k', domain='integer')
            sage: sin(1 + 2*k*pi)
            sin(1)
            sage: sin(k*pi)
            0

        TESTS::

            sage: conjugate(sin(x))
            sin(conjugate(x))
            sage: sin(complex(1,1))     # rel tol 1e-15
            (1.2984575814159773+0.6349639147847361j)

            sage: sin(pi/5)
            1/4*sqrt(-2*sqrt(5) + 10)
            sage: sin(pi/8)
            1/2*sqrt(-sqrt(2) + 2)
            sage: sin(pi/24)
            1/4*sqrt(-2*sqrt(6) - 2*sqrt(2) + 8)
            sage: sin(pi/30)
            -1/8*sqrt(5) + 1/4*sqrt(-3/2*sqrt(5) + 15/2) - 1/8
            sage: sin(104*pi/105)
            sin(1/105*pi)
            sage: cos(pi/8)
            1/2*sqrt(sqrt(2) + 2)
            sage: cos(pi/10)
            1/4*sqrt(2*sqrt(5) + 10)
            sage: cos(pi/12)
            1/4*sqrt(6) + 1/4*sqrt(2)
            sage: cos(pi/15)
            1/8*sqrt(5) + 1/4*sqrt(3/2*sqrt(5) + 15/2) - 1/8
            sage: cos(pi/24)
            1/4*sqrt(2*sqrt(6) + 2*sqrt(2) + 8)
            sage: cos(104*pi/105)
            -cos(1/105*pi)
            sage: tan(pi/5)
            sqrt(-2*sqrt(5) + 5)
            sage: tan(pi/8)
            sqrt(2) - 1
            sage: tan(pi/10)
            1/5*sqrt(-10*sqrt(5) + 25)
            sage: tan(pi/16)
            -sqrt(2) + sqrt(2*sqrt(2) + 4) - 1
            sage: tan(pi/20)
            sqrt(5) - sqrt(2*sqrt(5) + 5) + 1
            sage: tan(pi/24)
            sqrt(6) - sqrt(3) + sqrt(2) - 2
            sage: tan(104*pi/105)
            -tan(1/105*pi)
            sage: cot(104*pi/105)
            -cot(1/105*pi)
            sage: sec(104*pi/105)
            -sec(1/105*pi)
            sage: csc(104*pi/105)
            csc(1/105*pi)

            sage: all(sin(rat*pi).n(200)-sin(rat*pi,hold=True).n(200) < 1e-30 for rat in [1/5,2/5,1/30,7/30,11/30,13/30,1/8,3/8,1/24,5/24,7/24,11/24])
            True
            sage: all(cos(rat*pi).n(200)-cos(rat*pi,hold=True).n(200) < 1e-30 for rat in [1/10,3/10,1/12,5/12,1/15,2/15,4/15,7/15,1/8,3/8,1/24,5/24,11/24])
            True
            sage: all(tan(rat*pi).n(200)-tan(rat*pi,hold=True).n(200) < 1e-30 for rat in [1/5,2/5,1/10,3/10,1/20,3/20,7/20,9/20,1/8,3/8,1/16,3/16,5/16,7/16,1/24,5/24,7/24,11/24])
            True

        Check that :trac:`20456` is fixed::

            sage: assume(x>0)
            sage: sin(pi*x)
            sin(pi*x)
            sage: forget()

        Check that :trac:`20752` is fixed::

            sage: sin(3*pi+41/42*pi)
            -sin(1/42*pi)
            sage: sin(-5*pi+1/42*pi)
            -sin(1/42*pi)
            sage: sin(pi-1/42*pi)
            sin(1/42*pi)
        """
        GinacFunction.__init__(self,
                               'sin',
                               latex_name=r"\sin",
                               conversions=dict(maxima='sin',
                                                mathematica='Sin',
                                                giac='sin'))
Exemple #60
0
    def __init__(self):
        """
        The arctangent function.

        EXAMPLES::

            sage: arctan(1/2)
            arctan(1/2)
            sage: RDF(arctan(1/2))  # rel tol 1e-15
            0.46364760900080615
            sage: arctan(1 + I)
            arctan(I + 1)
            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

        ``conjugate(arctan(x))==arctan(conjugate(x))``, unless on the branch
        cuts which run along the imaginary axis outside the interval [-I, +I].::

            sage: conjugate(arctan(x))
            conjugate(arctan(x))
            sage: var('y', domain='positive')
            y
            sage: conjugate(arctan(y))
            arctan(y)
            sage: conjugate(arctan(y+I))
            conjugate(arctan(y + I))
            sage: conjugate(arctan(1/16))
            arctan(1/16)
            sage: conjugate(arctan(-2*I))
            conjugate(arctan(-2*I))
            sage: conjugate(arctan(2*I))
            conjugate(arctan(2*I))
            sage: conjugate(arctan(I/2))
            arctan(-1/2*I)

        TESTS::

            sage: arctan(x)._sympy_()
            atan(x)
            sage: arctan(x).operator()
            arctan
            sage: atan(complex(1,1))
            (1.0172219678978514+0.4023594781085251j)

        Check that :trac:`19918` is fixed::

            sage: arctan(-x).subs(x=oo)
            -1/2*pi
            sage: arctan(-x).subs(x=-oo)
            1/2*pi
        """
        GinacFunction.__init__(self,
                               'arctan',
                               latex_name=r"\arctan",
                               conversions=dict(maxima='atan',
                                                sympy='atan',
                                                fricas='atan',
                                                giac='atan'))