本文整理汇总了Python中sage.symbolic.function.BuiltinFunction类的典型用法代码示例。如果您正苦于以下问题:Python BuiltinFunction类的具体用法?Python BuiltinFunction怎么用?Python BuiltinFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BuiltinFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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")
示例2: __init__
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'))
示例3: __init__
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'))
示例4: __init__
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'))
示例5: __init__
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}")
示例6: __init__
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'))
示例7: __init__
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'))
示例8: __init__
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'})
示例9: __init__
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")
示例10: __init__
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'})
示例11: __init__
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'))
示例12: __init__
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'))
示例13: __init__
def __init__(self):
r"""
EXAMPLES::
sage: loads(dumps(elliptic_eu))
elliptic_eu
"""
BuiltinFunction.__init__(self, 'elliptic_eu', nargs=2,
conversions=dict(maxima='elliptic_eu'))
示例14: __init__
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"))
示例15: __init__
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'})