示例#1
0
    def __init__(self):
        r"""
        Symbolic `\min` function.

        The Python builtin `\min` function doesn't work as expected when symbolic
        expressions are given as arguments. This function delays evaluation
        until all symbolic arguments are substituted with values.

        EXAMPLES::

            sage: min_symbolic(3, x)
            min(3, x)
            sage: min_symbolic(3, x).subs(x=5)
            3
            sage: min_symbolic(3, 5, x)
            min(x, 3)
            sage: min_symbolic([3, 5, x])
            min(x, 3)

        TESTS::

            sage: loads(dumps(min_symbolic(x, 5)))
            min(x, 5)
            sage: latex(min_symbolic(x, 5))
            \min\left(x, 5\right)
            sage: min_symbolic(x, 5)._sympy_()
            Min(5, x)
        """
        BuiltinFunction.__init__(self, 'min', nargs=0, latex_name=r"\min",
                                 conversions=dict(sympy='Min'))
示例#2
0
    def __init__(self):
        r"""
        Symbolic `max` function.

        The Python builtin `max` function doesn't work as expected when symbolic
        expressions are given as arguments. This function delays evaluation
        until all symbolic arguments are substituted with values.

        EXAMPLES::

            sage: max_symbolic(3, x)
            max(3, x)
            sage: max_symbolic(3, x).subs(x=5)
            5
            sage: max_symbolic(3, 5, x)
            max(x, 5)
            sage: max_symbolic([3,5,x])
            max(x, 5)

        TESTS::

            sage: loads(dumps(max_symbolic(x,5)))
            max(x, 5)
            sage: latex(max_symbolic(x,5))
            \max\left(x, 5\right)
        """
        BuiltinFunction.__init__(self, 'max', nargs=0, latex_name="\max")
示例#3
0
    def __init__(self):
        """
        The arcsecant function.

        EXAMPLES::

            sage: arcsec(2)
            arcsec(2)
            sage: arcsec(2.0)
            1.04719755119660
            sage: RDF(arcsec(2))  # abs tol 1e-15
            1.0471975511965976
            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'))
示例#4
0
    def __init__(self):
        """
        Initialize class.

        EXAMPLES::

            sage: maxima(hypergeometric)
            hypergeometric

        TESTS::

            sage: F = hypergeometric([-4,2],[1],1)  # optional - maple
            sage: G = maple(F); G                   # optional - maple
            hypergeom([-4, 2],[1],1)
            sage: G.simplify()                      # optional - maple
            0
        """
        BuiltinFunction.__init__(self,
                                 'hypergeometric',
                                 nargs=3,
                                 conversions={
                                     'mathematica': 'HypergeometricPFQ',
                                     'maxima': 'hypergeometric',
                                     'maple': 'hypergeom',
                                     'sympy': 'hyper',
                                     'fricas': 'hypergeometricF'
                                 })
示例#5
0
    def __init__(self):
        """
        Class to represent an indefinite integral.

        EXAMPLES::

            sage: from sage.symbolic.integration.integral import indefinite_integral
            sage: indefinite_integral(log(x), x) #indirect doctest
            x*log(x) - x
            sage: indefinite_integral(x^2, x)
            1/3*x^3
            sage: indefinite_integral(4*x*log(x), x)
            2*x^2*log(x) - x^2
            sage: indefinite_integral(exp(x), 2*x)
            2*e^x

        """
        # The automatic evaluation routine will try these integrators
        # in the given order. This is an attribute of the class instead of
        # a global variable in this module to enable customization by
        # creating a subclasses which define a different set of integrators
        self.integrators = [external.maxima_integrator]

        BuiltinFunction.__init__(self, "integrate", nargs=2, conversions={'sympy': 'Integral',
                                                                          'giac': 'integrate'})
示例#6
0
文件: trig.py 项目: CETHop/sage
    def __init__(self):
        """
        The arcsecant function.

        EXAMPLES::

            sage: arcsec(2)
            arcsec(2)
            sage: RDF(arcsec(2))
            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'))
示例#7
0
    def __init__(self):
        """
        The arccotangent function.

        EXAMPLES::

            sage: arccot(1/2)
            arccot(1/2)
            sage: RDF(arccot(1/2))
            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', sympy='acot'))
示例#8
0
    def __init__(self):
        r"""
        The cosecant function.

        EXAMPLES::

            sage: csc(pi/4)
            sqrt(2)
            sage: RR(csc(pi/4))
            1.41421356237310
            sage: n(csc(pi/4),100)
            1.4142135623730950488016887242
            sage: csc(1/2)
            csc(1/2)
            sage: csc(0.5)
            2.08582964293349

            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")
示例#9
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

        """
        BuiltinFunction.__init__(self, "cot", latex_name=r"\cot")
示例#10
0
    def __init__(self):
        r"""
        The Dirac delta (generalized) function, ``dirac_delta(x)``.

        INPUT:

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

        EXAMPLES::

            sage: dirac_delta(1)
            0
            sage: dirac_delta(0)
            dirac_delta(0)
            sage: dirac_delta(x)
            dirac_delta(x)
            sage: latex(dirac_delta(x))
            \delta\left(x\right)

            sage: loads(dumps(dirac_delta(x)))
            dirac_delta(x)
            sage: dirac_delta(x)._sympy_()
            DiracDelta(x)
        """
        BuiltinFunction.__init__(self, "dirac_delta", latex_name=r"\delta",
                                   conversions=dict(maxima='delta',
                                                  mathematica='DiracDelta',
                                                  sympy='DiracDelta'))
示例#11
0
    def __init__(self,
                 name,
                 latex_name=None,
                 conversions=None,
                 evalf_float=None):
        """
        Note that subclasses of HyperbolicFunction should be instantiated only
        once, since they inherit from BuiltinFunction which only uses the
        name and class to check if a function was already registered.

        EXAMPLES::

            sage: from sage.functions.hyperbolic import HyperbolicFunction
            sage: class Barh(HyperbolicFunction):
            ....:     def __init__(self):
            ....:         HyperbolicFunction.__init__(self, 'barh')
            sage: barh = Barh()
            sage: barh(x)
            barh(x)
        """
        self._evalf_float = evalf_float
        BuiltinFunction.__init__(self,
                                 name,
                                 latex_name=latex_name,
                                 conversions=conversions)
示例#12
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
        """
        BuiltinFunction.__init__(self, "unit_step", latex_name=r"\mathrm{u}",
                                   conversions=dict(mathematica='UnitStep'))
示例#13
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)
        """
        BuiltinFunction.__init__(self, "heaviside", latex_name="H",
                                 conversions=dict(maxima='hstep',
                                                  mathematica='HeavisideTheta',
                                                  sympy='Heaviside'))
示例#14
0
    def __init__(self):
        """
        Class to represent an indefinite integral.

        EXAMPLES::

            sage: from sage.symbolic.integration.integral import indefinite_integral
            sage: indefinite_integral(log(x), x) #indirect doctest
            x*log(x) - x
            sage: indefinite_integral(x^2, x)
            1/3*x^3
            sage: indefinite_integral(4*x*log(x), x)
            2*x^2*log(x) - x^2
            sage: indefinite_integral(exp(x), 2*x)
            2*e^x

        """
        # The automatic evaluation routine will try these integrators
        # in the given order. This is an attribute of the class instead of
        # a global variable in this module to enable customization by
        # creating a subclasses which define a different set of integrators
        self.integrators = [external.maxima_integrator]

        BuiltinFunction.__init__(self,
                                 "integrate",
                                 nargs=2,
                                 conversions={'sympy': 'Integral'})
示例#15
0
    def __init__(self):
        """
        The arccosecant function.

        EXAMPLES::

            sage: arccsc(2)
            arccsc(2)
            sage: RDF(arccsc(2))
            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'))
示例#16
0
文件: error.py 项目: mcognetta/sage
    def __init__(self):
        r"""
        Initialize ``self``.

        EXAMPLES::

            sage: erfinv(2)._sympy_()
            erfinv(2)
            sage: maxima(erfinv(2))
            inverse_erf(2)

        TESTS:

        Check that :trac:`11349` is fixed::

            sage: _ = var('z,t')
            sage: PDF = exp(-x^2 /2)/sqrt(2*pi)
            sage: integralExpr = integrate(PDF,x,z,oo).subs(z==log(t))
            sage: y = solve(integralExpr==z,t)[0].rhs().subs(z==1/4)    
            sage: y
            e^(sqrt(2)*erfinv(1/2))
            sage: y.n()
            1.96303108415826
        """
        BuiltinFunction.__init__(self, "erfinv",
                                 latex_name=r"\operatorname{erfinv}",
                                 conversions=dict(sympy='erfinv',
                                                  maxima='inverse_erf'))
示例#17
0
文件: min_max.py 项目: Etn40ff/sage
    def __init__(self):
        r"""
        Symbolic `\max` function.

        The Python builtin `\max` function doesn't work as expected when symbolic
        expressions are given as arguments. This function delays evaluation
        until all symbolic arguments are substituted with values.

        EXAMPLES::

            sage: max_symbolic(3, x)
            max(3, x)
            sage: max_symbolic(3, x).subs(x=5)
            5
            sage: max_symbolic(3, 5, x)
            max(x, 5)
            sage: max_symbolic([3,5,x])
            max(x, 5)

        TESTS::

            sage: loads(dumps(max_symbolic(x,5)))
            max(x, 5)
            sage: latex(max_symbolic(x,5))
            \max\left(x, 5\right)
        """
        BuiltinFunction.__init__(self, 'max', nargs=0, latex_name="\max")
示例#18
0
文件: airy.py 项目: sagemath/sage
    def __init__(self):
        r"""
        The generalized derivative of the Airy Ai function

        INPUT:

        - ``alpha`` -- Return the `\alpha`-th order fractional derivative with
          respect to `z`.
          For `\alpha = n = 1,2,3,\ldots` this gives the derivative
          `\operatorname{Ai}^{(n)}(z)`, and for `\alpha = -n = -1,-2,-3,\ldots`
          this gives the `n`-fold iterated integral.

        .. MATH::

            f_0(z) = \operatorname{Ai}(z)

            f_n(z) = \int_0^z f_{n-1}(t) dt

        - ``x`` -- The argument of the function

        EXAMPLES::

            sage: from sage.functions.airy import airy_ai_general
            sage: x, n = var('x n')
            sage: airy_ai_general(-2, x)
            airy_ai(-2, x)
            sage: derivative(airy_ai_general(-2, x), x)
            airy_ai(-1, x)
            sage: airy_ai_general(n, x)
            airy_ai(n, x)
            sage: derivative(airy_ai_general(n, x), x)
            airy_ai(n + 1, x)
        """
        BuiltinFunction.__init__(self, "airy_ai", nargs=2,
                                 latex_name=r"\operatorname{Ai}")
示例#19
0
    def __init__(self):
        """
        Return the value of the complex exponential integral Ei(z) at a
        complex number z.

        EXAMPLES::

            sage: Ei(10)
            Ei(10)
            sage: Ei(I)
            Ei(I)
            sage: Ei(3+I)
            Ei(I + 3)
            sage: Ei(1.3)
            2.72139888023202

        The branch cut for this function is along the negative real axis::

            sage: Ei(-3 + 0.1*I)
            -0.0129379427181693 + 3.13993830250942*I
            sage: Ei(-3 - 0.1*I)
            -0.0129379427181693 - 3.13993830250942*I

        ALGORITHM: Uses mpmath.
        """
        BuiltinFunction.__init__(self, "Ei",
                                 conversions=dict(maxima='expintegral_ei'))
示例#20
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)
        """
        BuiltinFunction.__init__(self, "heaviside", latex_name="H",
                                 conversions=dict(maxima='hstep',
                                                  mathematica='HeavisideTheta',
                                                  sympy='Heaviside'))
示例#21
0
文件: min_max.py 项目: mcognetta/sage
    def __init__(self):
        r"""
        Symbolic `\min` function.

        The Python builtin `\min` function doesn't work as expected when symbolic
        expressions are given as arguments. This function delays evaluation
        until all symbolic arguments are substituted with values.

        EXAMPLES::

            sage: min_symbolic(3, x)
            min(3, x)
            sage: min_symbolic(3, x).subs(x=5)
            3
            sage: min_symbolic(3, 5, x)
            min(x, 3)
            sage: min_symbolic([3,5,x])
            min(x, 3)

        TESTS::

            sage: loads(dumps(min_symbolic(x,5)))
            min(x, 5)
            sage: latex(min_symbolic(x,5))
            \min\left(x, 5\right)
            sage: min_symbolic(x, 5)._sympy_()
            Min(5, x)
        """
        BuiltinFunction.__init__(self, 'min', nargs=0, latex_name="\min",
                                 conversions=dict(sympy='Min'))
示例#22
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
        """
        BuiltinFunction.__init__(self, "unit_step", latex_name=r"\mathrm{u}",
                                   conversions=dict(mathematica='UnitStep'))
示例#23
0
    def __init__(self):
        """
        The symbolic function representing a definite integral.

        EXAMPLES::

            sage: from sage.symbolic.integration.integral import definite_integral
            sage: definite_integral(sin(x),x,0,pi)
            2
        """
        # The automatic evaluation routine will try these integrators
        # in the given order. This is an attribute of the class instead of
        # a global variable in this module to enable customization by
        # creating a subclasses which define a different set of integrators
        self.integrators = [
            external.maxima_integrator, external.giac_integrator,
            external.sympy_integrator
        ]

        BuiltinFunction.__init__(self,
                                 "integrate",
                                 nargs=4,
                                 conversions={
                                     'sympy': 'Integral',
                                     'giac': 'integrate'
                                 })
示例#24
0
文件: trig.py 项目: CETHop/sage
    def __init__(self):
        """
        The arccotangent function.

        EXAMPLES::

            sage: arccot(1/2)
            arccot(1/2)
            sage: RDF(arccot(1/2))
            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', sympy='acot'))
示例#25
0
    def __init__(self):
        r"""
        The incomplete gamma function.

        EXAMPLES::

            sage: gamma_inc(CDF(0,1), 3)
            0.00320857499337 + 0.0124061858119*I
            sage: gamma_inc(RDF(1), 3)
            0.0497870683678639
            sage: gamma_inc(3,2)
            gamma(3, 2)
            sage: gamma_inc(x,0)
            gamma(x)
            sage: latex(gamma_inc(3,2))
            \Gamma\left(3, 2\right)
            sage: loads(dumps((gamma_inc(3,2))))
            gamma(3, 2)
            sage: i = ComplexField(30).0; gamma_inc(2, 1 + i)
            0.70709210 - 0.42035364*I
            sage: gamma_inc(2., 5)
            0.0404276819945128
        """
        BuiltinFunction.__init__(self,
                                 "gamma",
                                 nargs=2,
                                 latex_name=r"\Gamma",
                                 conversions={
                                     'maxima': 'gamma_incomplete',
                                     'mathematica': 'Gamma',
                                     'maple': 'GAMMA'
                                 })
示例#26
0
    def __init__(self):
        """
        Return the value of the complex exponential integral Ei(z) at a
        complex number z.

        EXAMPLES::

            sage: Ei(10)
            Ei(10)
            sage: Ei(I)
            Ei(I)
            sage: Ei(3+I)
            Ei(I + 3)
            sage: Ei(1.3)
            2.72139888023202

        The branch cut for this function is along the negative real axis::

            sage: Ei(-3 + 0.1*I)
            -0.0129379427181693 + 3.13993830250942*I
            sage: Ei(-3 - 0.1*I)
            -0.0129379427181693 - 3.13993830250942*I

        ALGORITHM: Uses mpmath.
        """
        BuiltinFunction.__init__(self,
                                 "Ei",
                                 conversions=dict(maxima='expintegral_ei'))
示例#27
0
文件: trig.py 项目: jwbober/sagelib
    def __init__(self):
        """
        The secant function

        EXAMPLES::

            sage: sec(pi/4)
            sqrt(2)
            sage: RR(sec(pi/4))
            1.41421356237310
            sage: n(sec(pi/4),100)
            1.4142135623730950488016887242       
            sage: sec(1/2)
            sec(1/2)
            sage: sec(0.5)
            1.13949392732455

            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")
示例#28
0
    def __init__(self):
        r"""
        The Dirac delta (generalized) function, ``dirac_delta(x)``.

        INPUT:

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

        EXAMPLES::

            sage: dirac_delta(1)
            0
            sage: dirac_delta(0)
            dirac_delta(0)
            sage: dirac_delta(x)
            dirac_delta(x)
            sage: latex(dirac_delta(x))
            \delta\left(x\right)

            sage: loads(dumps(dirac_delta(x)))
            dirac_delta(x)
        """
        BuiltinFunction.__init__(self, "dirac_delta", latex_name=r"\delta",
                                   conversions=dict(maxima='delta',
                                    mathematica='DiracDelta'))
示例#29
0
文件: other.py 项目: ppurka/sagelib
    def __init__(self):
        r"""
        The incomplete gamma function.

        EXAMPLES::

            sage: gamma_inc(CDF(0,1), 3)
            0.00320857499337 + 0.0124061858119*I
            sage: gamma_inc(RDF(1), 3)
            0.0497870683678639
            sage: gamma_inc(3,2)
            gamma(3, 2)
            sage: gamma_inc(x,0)
            gamma(x)
            sage: latex(gamma_inc(3,2))
            \Gamma\left(3, 2\right)
            sage: loads(dumps((gamma_inc(3,2))))
            gamma(3, 2)
            sage: i = ComplexField(30).0; gamma_inc(2, 1 + i)
            0.70709210 - 0.42035364*I
            sage: gamma_inc(2., 5)
            0.0404276819945128
        """
        BuiltinFunction.__init__(self, "gamma", nargs=2, latex_name=r"\Gamma",
                conversions={'maxima':'gamma_incomplete', 'mathematica':'Gamma',
                    'maple':'GAMMA'})
示例#30
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(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'))
示例#31
0
文件: trig.py 项目: CETHop/sage
    def __init__(self):
        r"""
        The cosecant function.

        EXAMPLES::

            sage: csc(pi/4)
            sqrt(2)
            sage: RR(csc(pi/4))
            1.41421356237310
            sage: n(csc(pi/4),100)
            1.4142135623730950488016887242
            sage: csc(1/2)
            csc(1/2)
            sage: csc(0.5)
            2.08582964293349

            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")
示例#32
0
文件: trig.py 项目: CETHop/sage
    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

        """
        BuiltinFunction.__init__(self, "cot", latex_name=r"\cot")
示例#33
0
文件: special.py 项目: robertwb/sage
    def __init__(self):
        r"""
        EXAMPLES::

            sage: loads(dumps(elliptic_eu))
            elliptic_eu
        """
        BuiltinFunction.__init__(self, 'elliptic_eu', nargs=2,
                                 conversions=dict(maxima='elliptic_eu'))
示例#34
0
    def __init__(self):
        r"""
        EXAMPLES::

            sage: loads(dumps(elliptic_eu))
            elliptic_eu
        """
        BuiltinFunction.__init__(self, 'elliptic_eu', nargs=2,
                                 conversions=dict(maxima='elliptic_eu'))
示例#35
0
    def __init__(self):
        """
        TESTS::

            sage: Ei(10)
            Ei(10)
            sage: Ei(x)._sympy_()
            Ei(x)
        """
        BuiltinFunction.__init__(self, "Ei", conversions=dict(maxima="expintegral_ei", sympy="Ei"))
示例#36
0
    def __init__(self):
        """
        Class to represent an indefinite integral.

        EXAMPLES::

            sage: from sage.symbolic.integration.integral import indefinite_integral
            sage: indefinite_integral(log(x), x) #indirect doctest
            x*log(x) - x
            sage: indefinite_integral(x^2, x)
            1/3*x^3
            sage: indefinite_integral(4*x*log(x), x)
            2*x^2*log(x) - x^2
            sage: indefinite_integral(exp(x), 2*x)
            2*e^x

        TESTS:

        Check for :trac:`28913`::

            sage: Ex = (1-2*x^(1/3))^(3/4)/x
            sage: integrate(Ex, x, algorithm="giac")  # long time
            4*(-2*x^(1/3) + 1)^(3/4) + 6*arctan((-2*x^(1/3) + 1)^(1/4)) - 3*log((-2*x^(1/3) + 1)^(1/4) + 1) + 3*log(abs((-2*x^(1/3) + 1)^(1/4) - 1))

        Check for :trac:`29833`::

            sage: (x,a,b)=var('x a b')
            sage: assume(b > 0)
            sage: f = (exp((x-a)/b) + 1)**(-1)
            sage: (f*f).integrate(x, algorithm="mathematica_free") # optional -- internet
            -b*log(e^(a/b) + e^(x/b)) + x + b/(e^(-(a - x)/b) + 1)

        Check for :trac:`25119`::

            sage: result = integrate(sqrt(x^2)/x,x)
            ...
            sage: result
            x*sgn(x)
        """
        # The automatic evaluation routine will try these integrators
        # in the given order. This is an attribute of the class instead of
        # a global variable in this module to enable customization by
        # creating a subclasses which define a different set of integrators
        self.integrators = [
            external.maxima_integrator, external.libgiac_integrator,
            external.sympy_integrator
        ]

        BuiltinFunction.__init__(self,
                                 "integrate",
                                 nargs=2,
                                 conversions={
                                     'sympy': 'Integral',
                                     'giac': 'integrate'
                                 })
示例#37
0
    def __init__(self):
        r"""
        EXAMPLES::

            sage: loads(dumps(harmonic_number(x,5)))
            harmonic_number(x, 5)
            sage: harmonic_number(x, x)._sympy_()
            harmonic(x, x)
        """
        BuiltinFunction.__init__(self, "harmonic_number", nargs=2,
                conversions={'sympy':'harmonic'})
示例#38
0
文件: log.py 项目: mcognetta/sage
    def __init__(self):
        r"""
        EXAMPLES::

            sage: loads(dumps(harmonic_number(x,5)))
            harmonic_number(x, 5)
            sage: harmonic_number(x, x)._sympy_()
            harmonic(x, x)
        """
        BuiltinFunction.__init__(self, "harmonic_number", nargs=2,
                conversions={'sympy':'harmonic'})
示例#39
0
    def __init__(self):
        r"""
        TESTS::

            sage: latex(hurwitz_zeta(x, 2))
            \zeta\left(x, 2\right)
            sage: hurwitz_zeta(x, 2)._sympy_()
            zeta(x, 2)
        """
        BuiltinFunction.__init__(
            self, "hurwitz_zeta", nargs=2, conversions=dict(mathematica="HurwitzZeta", sympy="zeta"), latex_name="\zeta"
        )
示例#40
0
    def __init__(self):
        r"""
        The lower incomplete gamma function.

        It is defined by the integral

        .. MATH::

            \Gamma(a,z)=\int_0^z t^{a-1}e^{-t}\,\mathrm{d}t

        EXAMPLES::

            sage: gamma_inc_lower(CDF(0,1), 3)
            -0.1581584032951798 - 0.5104218539302277*I
            sage: gamma_inc_lower(RDF(1), 3)
            0.950212931632136
            sage: gamma_inc_lower(3, 2, hold=True)
            gamma_inc_lower(3, 2)
            sage: gamma_inc_lower(3, 2)
            -10*e^(-2) + 2
            sage: gamma_inc_lower(x, 0)
            0
            sage: latex(gamma_inc_lower(x, x))
            \gamma\left(x, x\right)
            sage: loads(dumps((gamma_inc_lower(x, x))))
            gamma_inc_lower(x, x)
            sage: i = ComplexField(30).0; gamma_inc_lower(2, 1 + i)
            0.29290790 + 0.42035364*I
            sage: gamma_inc_lower(2., 5)
            0.959572318005487

        Interfaces to other software::

            sage: gamma_inc_lower(x,x)._sympy_()
            lowergamma(x, x)
            sage: maxima(gamma_inc_lower(x,x))
            gamma_greek(_SAGE_VAR_x,_SAGE_VAR_x)

    .. SEEALSO::

        :class:`Function_gamma_inc`
        """
        BuiltinFunction.__init__(self,
                                 "gamma_inc_lower",
                                 nargs=2,
                                 latex_name=r"\gamma",
                                 conversions={
                                     'maxima': 'gamma_greek',
                                     'mathematica': 'Gamma',
                                     'maple': 'GAMMA',
                                     'sympy': 'lowergamma',
                                     'giac': 'igamma'
                                 })
示例#41
0
    def __init__(self):
        r"""
        See the docstring for :meth:`Function_lambert_w`.

        EXAMPLES::

            sage: lambert_w(0, 1.0)
            0.567143290409784
        """
        BuiltinFunction.__init__(self, "lambert_w", nargs=2,
                                 conversions={'mathematica':'ProductLog',
                                              'maple':'LambertW'})
示例#42
0
文件: log.py 项目: ye-man/sage
    def __init__(self):
        r"""
        Representation of a complex number in a polar form.

        INPUT:

        - ``z`` - a complex number `z = a + ib`.

        OUTPUT:

        A complex number with modulus `\exp(a)` and argument `b`.

        If `-\pi < b \leq \pi` then `\operatorname{exp\_polar}(z)=\exp(z)`.
        For other values of `b` the function is left unevaluated.

        EXAMPLES:

        The following expressions are evaluated using the exponential
        function::

            sage: exp_polar(pi*I/2)
            I
            sage: x = var('x', domain='real')
            sage: exp_polar(-1/2*I*pi + x)
            e^(-1/2*I*pi + x)

        The function is left unevaluated when the imaginary part of the
        input `z` does not satisfy `-\pi < \Im(z) \leq \pi`::

            sage: exp_polar(2*pi*I)
            exp_polar(2*I*pi)
            sage: exp_polar(-4*pi*I)
            exp_polar(-4*I*pi)

        This fixes :trac:`18085`::

            sage: integrate(1/sqrt(1+x^3),x,algorithm='sympy')
            1/3*x*gamma(1/3)*hypergeometric((1/3, 1/2), (4/3,), -x^3)/gamma(4/3)


        .. SEEALSO::

            `Examples in Sympy documentation <http://docs.sympy.org/latest/modules/functions/special.html?highlight=exp_polar>`_,
            `Sympy source code of exp_polar <http://docs.sympy.org/0.7.4/_modules/sympy/functions/elementary/exponential.html>`_

        REFERENCES:

            :wikipedia:`Complex_number#Polar_form`
        """
        BuiltinFunction.__init__(self,
                                 "exp_polar",
                                 latex_name=r"\operatorname{exp\_polar}",
                                 conversions=dict(sympy='exp_polar'))
示例#43
0
    def __init__(self):
        """
        See the docstring for ``Function_log_integral-offset``.

        EXAMPLES::

            sage: log_integral_offset(3)
            log_integral(3) - log_integral(2)

        """
        BuiltinFunction.__init__(self, "log_integral_offset", nargs=1,
                                 latex_name=r'log_integral_offset')
示例#44
0
    def __init__(self):
        """
        TESTS::

            sage: Ei(10)
            Ei(10)
            sage: Ei(x)._sympy_()
            Ei(x)
        """
        BuiltinFunction.__init__(self, "Ei",
                                 conversions=dict(maxima='expintegral_ei',
                                                  sympy='Ei'))
示例#45
0
文件: log.py 项目: sagemath/sage
    def __init__(self):
        r"""
        Representation of a complex number in a polar form.

        INPUT:

        - ``z`` - a complex number `z = a + ib`.

        OUTPUT:

        A complex number with modulus `\exp(a)` and argument `b`.

        If `-\pi < b \leq \pi` then `\operatorname{exp\_polar}(z)=\exp(z)`.
        For other values of `b` the function is left unevaluated.

        EXAMPLES:

        The following expressions are evaluated using the exponential
        function::

            sage: exp_polar(pi*I/2)
            I
            sage: x = var('x', domain='real')
            sage: exp_polar(-1/2*I*pi + x)
            e^(-1/2*I*pi + x)

        The function is left unevaluated when the imaginary part of the
        input `z` does not satisfy `-\pi < \Im(z) \leq \pi`::

            sage: exp_polar(2*pi*I)
            exp_polar(2*I*pi)
            sage: exp_polar(-4*pi*I)
            exp_polar(-4*I*pi)

        This fixes :trac:`18085`::

            sage: integrate(1/sqrt(1+x^3),x,algorithm='sympy')
            1/3*x*gamma(1/3)*hypergeometric((1/3, 1/2), (4/3,), -x^3)/gamma(4/3)


        .. SEEALSO::

            `Examples in Sympy documentation <http://docs.sympy.org/latest/modules/functions/special.html?highlight=exp_polar>`_,
            `Sympy source code of exp_polar <http://docs.sympy.org/0.7.4/_modules/sympy/functions/elementary/exponential.html>`_

        REFERENCES:

            :wikipedia:`Complex_number#Polar_form`
        """
        BuiltinFunction.__init__(self, "exp_polar",
                                latex_name=r"\operatorname{exp\_polar}",
                                conversions=dict(sympy='exp_polar'))
示例#46
0
    def __init__(self):
        r"""
        The argument function for complex numbers.

        EXAMPLES::

            sage: arg(3+i)
            arctan(1/3)
            sage: arg(-1+i)
            3/4*pi
            sage: arg(2+2*i)
            1/4*pi
            sage: arg(2+x)
            arg(x + 2)
            sage: arg(2.0+i+x)
            arg(x + 2.00000000000000 + 1.00000000000000*I)
            sage: arg(-3)
            pi
            sage: arg(3)
            0
            sage: arg(0)
            0
            sage: latex(arg(x))
            {\rm arg}\left(x\right)
            sage: maxima(arg(x))
            atan2(0,x)
            sage: maxima(arg(2+i))
            atan(1/2)
            sage: maxima(arg(sqrt(2)+i))
            atan(1/sqrt(2))
            sage: arg(2+i)
            arctan(1/2)
            sage: arg(sqrt(2)+i)
            arg(sqrt(2) + I)
            sage: arg(sqrt(2)+i).simplify()
            arctan(1/2*sqrt(2))

        TESTS::

            sage: arg(0.0)
            0.000000000000000
            sage: arg(3.0)
            0.000000000000000
            sage: arg(-2.5)
            3.14159265358979
            sage: arg(2.0+3*i)
            0.982793723247329
        """
        BuiltinFunction.__init__(self,
                                 "arg",
                                 conversions=dict(maxima='carg',
                                                  mathematica='Arg'))
示例#47
0
    def __init__(self):
        r"""
        TESTS::

            sage: latex(hurwitz_zeta(x, 2))
            \zeta\left(x, 2\right)
            sage: hurwitz_zeta(x, 2)._sympy_()
            zeta(x, 2)
        """
        BuiltinFunction.__init__(self, 'hurwitz_zeta', nargs=2,
                                 conversions=dict(mathematica='HurwitzZeta',
                                                  sympy='zeta'),
                                 latex_name=r'\zeta')
示例#48
0
文件: bessel.py 项目: manguluka/sage
    def __init__(self):
        """
        See the docstring for :meth:`Function_Bessel_Y`.

        EXAMPLES::

            sage: sage.functions.bessel.Function_Bessel_Y()(0, x)
            bessel_Y(0, x)
        """
        BuiltinFunction.__init__(self, "bessel_Y", nargs=2,
                                 conversions=dict(mathematica='BesselY',
                                                  maxima='bessel_y',
                                                  sympy='bessely'))
示例#49
0
 def __init__(self):
     """
     EXAMPLES::
 
         sage: loads(dumps(elliptic_pi))
         elliptic_pi
         sage: elliptic_pi(x, pi/4, 1)._sympy_()
         elliptic_pi(x, pi/4, 1)
     """
     BuiltinFunction.__init__(self, 'elliptic_pi', nargs=3,
                              conversions=dict(mathematica='EllipticPi',
                                               maxima='EllipticPi',
                                               sympy='elliptic_pi'))
示例#50
0
    def __init__(self):
        """
        EXAMPLES::

            sage: loads(dumps(elliptic_f))
            elliptic_f
            sage: elliptic_f(x, 2)._sympy_()
            elliptic_f(x, 2)
        """
        BuiltinFunction.__init__(self, 'elliptic_f', nargs=2,
                                 conversions=dict(mathematica='EllipticF',
                                                  maxima='elliptic_f',
                                                  sympy='elliptic_f'))
示例#51
0
    def __init__(self):
        """
        See the docstring for :class:`Function_cos_integral`.

        EXAMPLES::

            sage: cos_integral(1)
            cos_integral(1)

        """
        BuiltinFunction.__init__(self, "cos_integral", nargs=1,
                                 latex_name=r'\operatorname{Ci}',
                                 conversions=dict(maxima='expintegral_ci'))
示例#52
0
文件: bessel.py 项目: manguluka/sage
    def __init__(self):
        """
        See the docstring for :meth:`Function_Bessel_I`.

        EXAMPLES::

            sage: bessel_I(1,x)
            bessel_I(1, x)
        """
        BuiltinFunction.__init__(self, "bessel_I", nargs=2,
                                 conversions=dict(mathematica='BesselI',
                                                  maxima='bessel_i',
                                                  sympy='besseli'))
示例#53
0
文件: bessel.py 项目: manguluka/sage
    def __init__(self):
        """
        See the docstring for :meth:`Function_Bessel_K`.

        EXAMPLES::

            sage: sage.functions.bessel.Function_Bessel_K()
            bessel_K
        """
        BuiltinFunction.__init__(self, "bessel_K", nargs=2,
                                 conversions=dict(mathematica='BesselK',
                                                  maxima='bessel_k',
                                                  sympy='besselk'))
示例#54
0
    def __init__(self):
        """
        See the docstring for ``Function_sin_integral``.

        EXAMPLES::

            sage: sin_integral(1)
            sin_integral(1)

        """
        BuiltinFunction.__init__(self, "sin_integral", nargs=1,
                                 latex_name=r'\operatorname{Si}',
                                 conversions=dict(maxima='expintegral_si'))
示例#55
0
    def __init__(self):
        """
        See the docstring for ``Function_log_integral``.

        EXAMPLES::

            sage: log_integral(3)
            log_integral(3)

        """
        BuiltinFunction.__init__(self, "log_integral", nargs=1,
                                 latex_name=r'log_integral',
                                 conversions=dict(maxima='expintegral_li'))
示例#56
0
    def __init__(self):
        """
        See the docstring for :class:`Function_exp_integral_e1`.

        EXAMPLES::

            sage: exp_integral_e1(1)
            exp_integral_e1(1)

        """
        BuiltinFunction.__init__(self, "exp_integral_e1", nargs=1,
                                 latex_name=r'exp_integral_e1',
                                 conversions=dict(maxima='expintegral_e1'))
示例#57
0
    def __init__(self):
        """
        See the docstring for :meth:`Function_exp_integral_e`.

        EXAMPLES::

            sage: exp_integral_e(1,0)
            exp_integral_e(1, 0)

        """
        BuiltinFunction.__init__(self, "exp_integral_e", nargs=2,
                                 latex_name=r'exp_integral_e',
                                 conversions=dict(maxima='expintegral_e'))
示例#58
0
文件: bessel.py 项目: Findstat/sage
    def __init__(self):
        """
        See the docstring for :meth:`Function_Bessel_I`.

        EXAMPLES::

            sage: bessel_I(1,x)
            bessel_I(1, x)
        """
        BuiltinFunction.__init__(self, "bessel_I", nargs=2,
                                 conversions=dict(mathematica='BesselI',
                                                  maxima='bessel_i',
                                                  sympy='besseli'))
示例#59
0
文件: bessel.py 项目: Findstat/sage
    def __init__(self):
        """
        See the docstring for :meth:`Function_Bessel_K`.

        EXAMPLES::

            sage: sage.functions.bessel.Function_Bessel_K()
            bessel_K
        """
        BuiltinFunction.__init__(self, "bessel_K", nargs=2,
                                 conversions=dict(mathematica='BesselK',
                                                  maxima='bessel_k',
                                                  sympy='besselk'))