本文整理汇总了Python中sympy.factorial2函数的典型用法代码示例。如果您正苦于以下问题:Python factorial2函数的具体用法?Python factorial2怎么用?Python factorial2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了factorial2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_factorial2_rewrite
def test_factorial2_rewrite():
n = Symbol('n', integer=True)
assert factorial2(n).rewrite(gamma) == \
2**(n/2)*Piecewise((1, Eq(Mod(n, 2), 0)), (sqrt(2)/sqrt(pi), Eq(Mod(n, 2), 1)))*gamma(n/2 + 1)
assert factorial2(2*n).rewrite(gamma) == 2**n*gamma(n + 1)
assert factorial2(2*n + 1).rewrite(gamma) == \
sqrt(2)*2**(n + 1/2)*gamma(n + 3/2)/sqrt(pi)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:7,代码来源:test_comb_factorials.py
示例2: test_factorial2
def test_factorial2():
n = Symbol('n', integer=True)
assert factorial2(-1) == 1
assert factorial2(0) == 1
assert factorial2(7) == 105
assert factorial2(8) == 384
assert factorial2(n).func == Factorial2
开发者ID:addisonc,项目名称:sympy,代码行数:7,代码来源:test_comb_factorials.py
示例3: test_latex_functions
def test_latex_functions():
assert latex(exp(x)) == "e^{x}"
assert latex(exp(1)+exp(2)) == "e + e^{2}"
f = Function('f')
assert latex(f(x)) == '\\operatorname{f}{\\left (x \\right )}'
beta = Function('beta')
assert latex(beta(x)) == r"\beta{\left (x \right )}"
assert latex(sin(x)) == r"\sin{\left (x \right )}"
assert latex(sin(x), fold_func_brackets=True) == r"\sin {x}"
assert latex(sin(2*x**2), fold_func_brackets=True) == \
r"\sin {2 x^{2}}"
assert latex(sin(x**2), fold_func_brackets=True) == \
r"\sin {x^{2}}"
assert latex(asin(x)**2) == r"\operatorname{asin}^{2}{\left (x \right )}"
assert latex(asin(x)**2,inv_trig_style="full") == \
r"\arcsin^{2}{\left (x \right )}"
assert latex(asin(x)**2,inv_trig_style="power") == \
r"\sin^{-1}{\left (x \right )}^{2}"
assert latex(asin(x**2),inv_trig_style="power",fold_func_brackets=True) == \
r"\sin^{-1} {x^{2}}"
assert latex(factorial(k)) == r"k!"
assert latex(factorial(-k)) == r"\left(- k\right)!"
assert latex(factorial2(k)) == r"k!!"
assert latex(factorial2(-k)) == r"\left(- k\right)!!"
assert latex(binomial(2,k)) == r"{\binom{2}{k}}"
assert latex(FallingFactorial(3,k)) == r"{\left(3\right)}_{\left(k\right)}"
assert latex(RisingFactorial(3,k)) == r"{\left(3\right)}^{\left(k\right)}"
assert latex(floor(x)) == r"\lfloor{x}\rfloor"
assert latex(ceiling(x)) == r"\lceil{x}\rceil"
assert latex(Abs(x)) == r"\lvert{x}\rvert"
assert latex(re(x)) == r"\Re{x}"
assert latex(re(x+y)) == r"\Re {\left (x + y \right )}"
assert latex(im(x)) == r"\Im{x}"
assert latex(conjugate(x)) == r"\overline{x}"
assert latex(gamma(x)) == r"\Gamma\left(x\right)"
assert latex(Order(x)) == r"\mathcal{O}\left(x\right)"
assert latex(lowergamma(x, y)) == r'\gamma\left(x, y\right)'
assert latex(uppergamma(x, y)) == r'\Gamma\left(x, y\right)'
assert latex(cot(x)) == r'\cot{\left (x \right )}'
assert latex(coth(x)) == r'\coth{\left (x \right )}'
assert latex(re(x)) == r'\Re{x}'
assert latex(im(x)) == r'\Im{x}'
assert latex(root(x,y)) == r'x^{\frac{1}{y}}'
assert latex(arg(x)) == r'\arg{\left (x \right )}'
assert latex(zeta(x)) == r'\zeta{\left (x \right )}'
开发者ID:songuke,项目名称:sympy,代码行数:55,代码来源:test_latex.py
示例4: test_factorial
def test_factorial():
n = Symbol('n', integer=True)
assert str(factorial(-2)) == "0"
assert str(factorial(0)) == "1"
assert str(factorial(7)) == "5040"
assert str(factorial(n)) == "n!"
assert str(factorial(2*n)) == "(2*n)!"
assert str(factorial(factorial(n))) == '(n!)!'
assert str(factorial(factorial2(n))) == '(n!!)!'
assert str(factorial2(factorial(n))) == '(n!)!!'
assert str(factorial2(factorial2(n))) == '(n!!)!!'
开发者ID:FireJade,项目名称:sympy,代码行数:11,代码来源:test_str.py
示例5: test_factorial
def test_factorial():
n = Symbol('n', integer=True)
assert str(factorial(-2)) == "zoo"
assert str(factorial(0)) == "1"
assert str(factorial(7)) == "5040"
assert str(factorial(n)) == "factorial(n)"
assert str(factorial(2*n)) == "factorial(2*n)"
assert str(factorial(factorial(n))) == 'factorial(factorial(n))'
assert str(factorial(factorial2(n))) == 'factorial(factorial2(n))'
assert str(factorial2(factorial(n))) == 'factorial2(factorial(n))'
assert str(factorial2(factorial2(n))) == 'factorial2(factorial2(n))'
assert str(subfactorial(3)) == "2"
assert str(subfactorial(n)) == "subfactorial(n)"
assert str(subfactorial(2*n)) == "subfactorial(2*n)"
开发者ID:Lenqth,项目名称:sympy,代码行数:14,代码来源:test_str.py
示例6: test_factorial2
def test_factorial2():
n = Symbol('n', integer=True)
assert factorial2(-1) == 1
assert factorial2(0) == 1
assert factorial2(7) == 105
assert factorial2(8) == 384
# The following is exhaustive
tt = Symbol('tt', integer=True, nonnegative=True)
tte = Symbol('tte', even=True, nonnegative=True)
tpe = Symbol('tpe', even=True, positive=True)
tto = Symbol('tto', odd=True, nonnegative=True)
tf = Symbol('tf', integer=True, nonnegative=False)
tfe = Symbol('tfe', even=True, nonnegative=False)
tfo = Symbol('tfo', odd=True, nonnegative=False)
ft = Symbol('ft', integer=False, nonnegative=True)
ff = Symbol('ff', integer=False, nonnegative=False)
fn = Symbol('fn', integer=False)
nt = Symbol('nt', nonnegative=True)
nf = Symbol('nf', nonnegative=False)
nn = Symbol('nn')
#Solves and Fixes Issue #10388 - This is the updated test for the same solved issue
raises (ValueError, lambda: factorial2(oo))
raises (ValueError, lambda: factorial2(S(5)/2))
assert factorial2(n).is_integer is None
assert factorial2(tt - 1).is_integer
assert factorial2(tte - 1).is_integer
assert factorial2(tpe - 3).is_integer
assert factorial2(tto - 4).is_integer
assert factorial2(tto - 2).is_integer
assert factorial2(tf).is_integer is None
assert factorial2(tfe).is_integer is None
assert factorial2(tfo).is_integer is None
assert factorial2(ft).is_integer is None
assert factorial2(ff).is_integer is None
assert factorial2(fn).is_integer is None
assert factorial2(nt).is_integer is None
assert factorial2(nf).is_integer is None
assert factorial2(nn).is_integer is None
assert factorial2(n).is_positive is None
assert factorial2(tt - 1).is_positive is True
assert factorial2(tte - 1).is_positive is True
assert factorial2(tpe - 3).is_positive is True
assert factorial2(tpe - 1).is_positive is True
assert factorial2(tto - 2).is_positive is True
assert factorial2(tto - 1).is_positive is True
assert factorial2(tf).is_positive is None
assert factorial2(tfe).is_positive is None
assert factorial2(tfo).is_positive is None
assert factorial2(ft).is_positive is None
assert factorial2(ff).is_positive is None
assert factorial2(fn).is_positive is None
assert factorial2(nt).is_positive is None
assert factorial2(nf).is_positive is None
assert factorial2(nn).is_positive is None
assert factorial2(tt).is_even is None
assert factorial2(tt).is_odd is None
assert factorial2(tte).is_even is None
assert factorial2(tte).is_odd is None
assert factorial2(tte + 2).is_even is True
assert factorial2(tpe).is_even is True
assert factorial2(tto).is_odd is True
assert factorial2(tf).is_even is None
assert factorial2(tf).is_odd is None
assert factorial2(tfe).is_even is None
assert factorial2(tfe).is_odd is None
assert factorial2(tfo).is_even is False
assert factorial2(tfo).is_odd is None
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:71,代码来源:test_comb_factorials.py
示例7: test_factorial2
def test_factorial2():
n = Symbol('n', integer=True)
assert factorial2(-1) == 1
assert factorial2(0) == 1
assert factorial2(7) == 105
assert factorial2(8) == 384
assert factorial2(n).func == factorial2
# The following is exhaustive
tt = Symbol('tt', integer=True, nonnegative=True)
tf = Symbol('tf', integer=True, nonnegative=False)
ft = Symbol('ft', integer=False, nonnegative=True)
ff = Symbol('ff', integer=False, nonnegative=False)
fn = Symbol('fn', integer=False)
nt = Symbol('nt', nonnegative=True)
nf = Symbol('nf', nonnegative=False)
nn = Symbol('nn')
assert factorial2(tt - 1).is_integer
assert factorial2(tf - 1).is_integer is False
assert factorial2(n).is_integer is None
assert factorial2(ft - 1).is_integer is False
assert factorial2(ff - 1).is_integer is False
assert factorial2(fn).is_integer is False
assert factorial2(nt - 1).is_integer is None
assert factorial2(nf - 1).is_integer is False
assert factorial2(nn).is_integer is None
assert factorial2(tt - 1).is_positive
assert factorial2(tf - 1).is_positive is False
assert factorial2(n).is_positive is None
assert factorial2(ft - 1).is_positive is False
assert factorial2(ff - 1).is_positive is False
assert factorial2(fn).is_positive is False
assert factorial2(nt - 1).is_positive is None
assert factorial2(nf - 1).is_positive is False
assert factorial2(nn).is_positive is None
开发者ID:rahvar,项目名称:sympy,代码行数:37,代码来源:test_comb_factorials.py
示例8: var
from sympy.printing import ccode
nmax = 30
xi = var('xi')
u = map(sympify, ['1./2. - 3./4.*xi + 1./4.*xi**3',
'1./8. - 1./8.*xi - 1./8.*xi**2 + 1./8.*xi**3',
'1./2. + 3./4.*xi - 1./4.*xi**3',
'-1./8. - 1./8.*xi + 1./8.*xi**2 + 1./8.*xi**3'])
for r in range(5, nmax+1):
utmp = []
for n in range(0, r//2+1):
den = 2**n*factorial(n)*factorial(r-2*n-1)
utmp.append((-1)**n*factorial2(2*r - 2*n - 7)/den * xi**(r-2*n-1)/1.)
u.append(sum(utmp))
with open('../../../compmech/lib/src/bardell_functions.c', 'w') as f:
f.write("// Bardell's hierarchical functions\n\n")
f.write('// Number of terms: {0}\n\n'.format(len(u)))
f.write('#include <stdlib.h>\n')
f.write('#include <math.h>\n\n')
f.write('#if defined(_WIN32) || defined(__WIN32__)\n')
f.write(' #define EXPORTIT __declspec(dllexport)\n')
f.write('#else\n')
f.write(' #define EXPORTIT\n')
f.write('#endif\n\n')
f.write('EXPORTIT void calc_vec_f(double *f, double xi,\n' +
' double xi1t, double xi1r, double xi2t, double xi2r) {\n')
consts = {0:'xi1t', 1:'xi1r', 2:'xi2t', 3:'xi2r'}
开发者ID:compmech,项目名称:compmech,代码行数:31,代码来源:bardell_functions_C.py
示例9: test_latex_functions
def test_latex_functions():
assert latex(exp(x)) == "e^{x}"
assert latex(exp(1) + exp(2)) == "e + e^{2}"
f = Function("f")
assert latex(f(x)) == "\\operatorname{f}{\\left (x \\right )}"
beta = Function("beta")
assert latex(beta(x)) == r"\beta{\left (x \right )}"
assert latex(sin(x)) == r"\sin{\left (x \right )}"
assert latex(sin(x), fold_func_brackets=True) == r"\sin {x}"
assert latex(sin(2 * x ** 2), fold_func_brackets=True) == r"\sin {2 x^{2}}"
assert latex(sin(x ** 2), fold_func_brackets=True) == r"\sin {x^{2}}"
assert latex(asin(x) ** 2) == r"\operatorname{asin}^{2}{\left (x \right )}"
assert latex(asin(x) ** 2, inv_trig_style="full") == r"\arcsin^{2}{\left (x \right )}"
assert latex(asin(x) ** 2, inv_trig_style="power") == r"\sin^{-1}{\left (x \right )}^{2}"
assert latex(asin(x ** 2), inv_trig_style="power", fold_func_brackets=True) == r"\sin^{-1} {x^{2}}"
assert latex(factorial(k)) == r"k!"
assert latex(factorial(-k)) == r"\left(- k\right)!"
assert latex(subfactorial(k)) == r"!k"
assert latex(subfactorial(-k)) == r"!\left(- k\right)"
assert latex(factorial2(k)) == r"k!!"
assert latex(factorial2(-k)) == r"\left(- k\right)!!"
assert latex(binomial(2, k)) == r"{\binom{2}{k}}"
assert latex(FallingFactorial(3, k)) == r"{\left(3\right)}_{\left(k\right)}"
assert latex(RisingFactorial(3, k)) == r"{\left(3\right)}^{\left(k\right)}"
assert latex(floor(x)) == r"\lfloor{x}\rfloor"
assert latex(ceiling(x)) == r"\lceil{x}\rceil"
assert latex(Min(x, 2, x ** 3)) == r"\min\left(2, x, x^{3}\right)"
assert latex(Min(x, y) ** 2) == r"\min\left(x, y\right)^{2}"
assert latex(Max(x, 2, x ** 3)) == r"\max\left(2, x, x^{3}\right)"
assert latex(Max(x, y) ** 2) == r"\max\left(x, y\right)^{2}"
assert latex(Abs(x)) == r"\lvert{x}\rvert"
assert latex(re(x)) == r"\Re{x}"
assert latex(re(x + y)) == r"\Re{x} + \Re{y}"
assert latex(im(x)) == r"\Im{x}"
assert latex(conjugate(x)) == r"\overline{x}"
assert latex(gamma(x)) == r"\Gamma\left(x\right)"
assert latex(Order(x)) == r"\mathcal{O}\left(x\right)"
assert latex(lowergamma(x, y)) == r"\gamma\left(x, y\right)"
assert latex(uppergamma(x, y)) == r"\Gamma\left(x, y\right)"
assert latex(cot(x)) == r"\cot{\left (x \right )}"
assert latex(coth(x)) == r"\coth{\left (x \right )}"
assert latex(re(x)) == r"\Re{x}"
assert latex(im(x)) == r"\Im{x}"
assert latex(root(x, y)) == r"x^{\frac{1}{y}}"
assert latex(arg(x)) == r"\arg{\left (x \right )}"
assert latex(zeta(x)) == r"\zeta\left(x\right)"
assert latex(zeta(x)) == r"\zeta\left(x\right)"
assert latex(zeta(x) ** 2) == r"\zeta^{2}\left(x\right)"
assert latex(zeta(x, y)) == r"\zeta\left(x, y\right)"
assert latex(zeta(x, y) ** 2) == r"\zeta^{2}\left(x, y\right)"
assert latex(dirichlet_eta(x)) == r"\eta\left(x\right)"
assert latex(dirichlet_eta(x) ** 2) == r"\eta^{2}\left(x\right)"
assert latex(polylog(x, y)) == r"\operatorname{Li}_{x}\left(y\right)"
assert latex(polylog(x, y) ** 2) == r"\operatorname{Li}_{x}^{2}\left(y\right)"
assert latex(lerchphi(x, y, n)) == r"\Phi\left(x, y, n\right)"
assert latex(lerchphi(x, y, n) ** 2) == r"\Phi^{2}\left(x, y, n\right)"
assert latex(Ei(x)) == r"\operatorname{Ei}{\left (x \right )}"
assert latex(Ei(x) ** 2) == r"\operatorname{Ei}^{2}{\left (x \right )}"
assert latex(expint(x, y) ** 2) == r"\operatorname{E}_{x}^{2}\left(y\right)"
assert latex(Shi(x) ** 2) == r"\operatorname{Shi}^{2}{\left (x \right )}"
assert latex(Si(x) ** 2) == r"\operatorname{Si}^{2}{\left (x \right )}"
assert latex(Ci(x) ** 2) == r"\operatorname{Ci}^{2}{\left (x \right )}"
assert latex(Chi(x) ** 2) == r"\operatorname{Chi}^{2}{\left (x \right )}"
assert latex(jacobi(n, a, b, x)) == r"P_{n}^{\left(a,b\right)}\left(x\right)"
assert latex(jacobi(n, a, b, x) ** 2) == r"\left(P_{n}^{\left(a,b\right)}\left(x\right)\right)^{2}"
assert latex(gegenbauer(n, a, x)) == r"C_{n}^{\left(a\right)}\left(x\right)"
assert latex(gegenbauer(n, a, x) ** 2) == r"\left(C_{n}^{\left(a\right)}\left(x\right)\right)^{2}"
assert latex(chebyshevt(n, x)) == r"T_{n}\left(x\right)"
assert latex(chebyshevt(n, x) ** 2) == r"\left(T_{n}\left(x\right)\right)^{2}"
assert latex(chebyshevu(n, x)) == r"U_{n}\left(x\right)"
assert latex(chebyshevu(n, x) ** 2) == r"\left(U_{n}\left(x\right)\right)^{2}"
assert latex(legendre(n, x)) == r"P_{n}\left(x\right)"
assert latex(legendre(n, x) ** 2) == r"\left(P_{n}\left(x\right)\right)^{2}"
assert latex(assoc_legendre(n, a, x)) == r"P_{n}^{\left(a\right)}\left(x\right)"
assert latex(assoc_legendre(n, a, x) ** 2) == r"\left(P_{n}^{\left(a\right)}\left(x\right)\right)^{2}"
assert latex(laguerre(n, x)) == r"L_{n}\left(x\right)"
assert latex(laguerre(n, x) ** 2) == r"\left(L_{n}\left(x\right)\right)^{2}"
assert latex(assoc_laguerre(n, a, x)) == r"L_{n}^{\left(a\right)}\left(x\right)"
assert latex(assoc_laguerre(n, a, x) ** 2) == r"\left(L_{n}^{\left(a\right)}\left(x\right)\right)^{2}"
assert latex(hermite(n, x)) == r"H_{n}\left(x\right)"
assert latex(hermite(n, x) ** 2) == r"\left(H_{n}\left(x\right)\right)^{2}"
# Test latex printing of function names with "_"
assert latex(polar_lift(0)) == r"\operatorname{polar\_lift}{\left (0 \right )}"
assert latex(polar_lift(0) ** 3) == r"\operatorname{polar\_lift}^{3}{\left (0 \right )}"
开发者ID:kushal124,项目名称:sympy,代码行数:99,代码来源:test_latex.py
示例10: test_factorial2
def test_factorial2():
n = Symbol('n', integer=True)
assert factorial2(-1) == 1
assert factorial2(0) == 1
assert factorial2(7) == 105
assert factorial2(8) == 384
assert factorial2(n).func == factorial2
# The following is exhaustive
tt = Symbol('tt', integer=True, nonnegative=True)
tte = Symbol('tte', even=True, nonnegative=True)
tpe = Symbol('tpe', even=True, positive=True)
tto = Symbol('tto', odd=True, nonnegative=True)
tf = Symbol('tf', integer=True, nonnegative=False)
tfe = Symbol('tfe', even=True, nonnegative=False)
tfo = Symbol('tfo', odd=True, nonnegative=False)
ft = Symbol('ft', integer=False, nonnegative=True)
ff = Symbol('ff', integer=False, nonnegative=False)
fn = Symbol('fn', integer=False)
nt = Symbol('nt', nonnegative=True)
nf = Symbol('nf', nonnegative=False)
nn = Symbol('nn')
assert factorial2(n).is_integer is None
assert factorial2(tt - 1).is_integer
assert factorial2(tte - 1).is_integer
assert factorial2(tpe - 3).is_integer
# This should work, but it doesn't due to ...
# assert factorial2(tto - 4).is_integer
assert factorial2(tto - 2).is_integer
assert factorial2(tf).is_integer is None
assert factorial2(tfe).is_integer is None
assert factorial2(tfo).is_integer is None
assert factorial2(ft).is_integer is None
assert factorial2(ff).is_integer is None
assert factorial2(fn).is_integer is None
assert factorial2(nt).is_integer is None
assert factorial2(nf).is_integer is None
assert factorial2(nn).is_integer is None
assert factorial2(n).is_positive is None
assert factorial2(tt - 1).is_positive is True
assert factorial2(tte - 1).is_positive is True
# This should work, but it doesn't due to ...
# assert factorial2(tpe - 3).is_positive is True
assert factorial2(tpe - 1).is_positive is True
# This should work, but it doesn't due to ...
# assert factorial2(tto - 2).is_positive is True
assert factorial2(tto - 1).is_positive is True
assert factorial2(tf).is_positive is None
assert factorial2(tfe).is_positive is None
assert factorial2(tfo).is_positive is None
assert factorial2(ft).is_positive is None
assert factorial2(ff).is_positive is None
assert factorial2(fn).is_positive is None
assert factorial2(nt).is_positive is None
assert factorial2(nf).is_positive is None
assert factorial2(nn).is_positive is None
assert factorial2(tt).is_even is None
assert factorial2(tt).is_odd is None
assert factorial2(tte).is_even is None
assert factorial2(tte).is_odd is None
assert factorial2(tte + 2).is_even is True
assert factorial2(tpe).is_even is True
assert factorial2(tto).is_odd is True
assert factorial2(tf).is_even is None
assert factorial2(tf).is_odd is None
assert factorial2(tfe).is_even is None
assert factorial2(tfe).is_odd is None
assert factorial2(tfo).is_even is False
assert factorial2(tfo).is_odd is None
开发者ID:artcompiler,项目名称:artcompiler.github.com,代码行数:73,代码来源:test_comb_factorials.py
示例11: test_C3
def test_C3():
assert (factorial2(10), factorial2(9)) == (3840, 945)
开发者ID:batya239,项目名称:sympy,代码行数:2,代码来源:test_wester.py
示例12: test_F3
def test_F3():
assert combsimp(2**n * factorial(n) * factorial2(2*n - 1)) == factorial(2*n)
开发者ID:batya239,项目名称:sympy,代码行数:2,代码来源:test_wester.py
示例13: test_latex_functions
def test_latex_functions():
assert latex(exp(x)) == "e^{x}"
assert latex(exp(1) + exp(2)) == "e + e^{2}"
f = Function('f')
assert latex(f(x)) == r'f{\left (x \right )}'
assert latex(f) == r'f'
g = Function('g')
assert latex(g(x, y)) == r'g{\left (x,y \right )}'
assert latex(g) == r'g'
h = Function('h')
assert latex(h(x, y, z)) == r'h{\left (x,y,z \right )}'
assert latex(h) == r'h'
Li = Function('Li')
assert latex(Li) == r'\operatorname{Li}'
assert latex(Li(x)) == r'\operatorname{Li}{\left (x \right )}'
beta = Function('beta')
# not to be confused with the beta function
assert latex(beta(x)) == r"\beta{\left (x \right )}"
assert latex(beta) == r"\beta"
assert latex(sin(x)) == r"\sin{\left (x \right )}"
assert latex(sin(x), fold_func_brackets=True) == r"\sin {x}"
assert latex(sin(2*x**2), fold_func_brackets=True) == \
r"\sin {2 x^{2}}"
assert latex(sin(x**2), fold_func_brackets=True) == \
r"\sin {x^{2}}"
assert latex(asin(x)**2) == r"\operatorname{asin}^{2}{\left (x \right )}"
assert latex(asin(x)**2, inv_trig_style="full") == \
r"\arcsin^{2}{\left (x \right )}"
assert latex(asin(x)**2, inv_trig_style="power") == \
r"\sin^{-1}{\left (x \right )}^{2}"
assert latex(asin(x**2), inv_trig_style="power",
fold_func_brackets=True) == \
r"\sin^{-1} {x^{2}}"
assert latex(factorial(k)) == r"k!"
assert latex(factorial(-k)) == r"\left(- k\right)!"
assert latex(subfactorial(k)) == r"!k"
assert latex(subfactorial(-k)) == r"!\left(- k\right)"
assert latex(factorial2(k)) == r"k!!"
assert latex(factorial2(-k)) == r"\left(- k\right)!!"
assert latex(binomial(2, k)) == r"{\binom{2}{k}}"
assert latex(
FallingFactorial(3, k)) == r"{\left(3\right)}_{\left(k\right)}"
assert latex(RisingFactorial(3, k)) == r"{\left(3\right)}^{\left(k\right)}"
assert latex(floor(x)) == r"\lfloor{x}\rfloor"
assert latex(ceiling(x)) == r"\lceil{x}\rceil"
assert latex(Min(x, 2, x**3)) == r"\min\left(2, x, x^{3}\right)"
assert latex(Min(x, y)**2) == r"\min\left(x, y\right)^{2}"
assert latex(Max(x, 2, x**3)) == r"\max\left(2, x, x^{3}\right)"
assert latex(Max(x, y)**2) == r"\max\left(x, y\right)^{2}"
assert latex(Abs(x)) == r"\left\lvert{x}\right\rvert"
assert latex(re(x)) == r"\Re{x}"
assert latex(re(x + y)) == r"\Re{x} + \Re{y}"
assert latex(im(x)) == r"\Im{x}"
assert latex(conjugate(x)) == r"\overline{x}"
assert latex(gamma(x)) == r"\Gamma\left(x\right)"
assert latex(Order(x)) == r"\mathcal{O}\left(x\right)"
assert latex(lowergamma(x, y)) == r'\gamma\left(x, y\right)'
assert latex(uppergamma(x, y)) == r'\Gamma\left(x, y\right)'
assert latex(cot(x)) == r'\cot{\left (x \right )}'
assert latex(coth(x)) == r'\coth{\left (x \right )}'
assert latex(re(x)) == r'\Re{x}'
assert latex(im(x)) == r'\Im{x}'
assert latex(root(x, y)) == r'x^{\frac{1}{y}}'
assert latex(arg(x)) == r'\arg{\left (x \right )}'
assert latex(zeta(x)) == r'\zeta\left(x\right)'
assert latex(zeta(x)) == r"\zeta\left(x\right)"
assert latex(zeta(x)**2) == r"\zeta^{2}\left(x\right)"
assert latex(zeta(x, y)) == r"\zeta\left(x, y\right)"
assert latex(zeta(x, y)**2) == r"\zeta^{2}\left(x, y\right)"
assert latex(dirichlet_eta(x)) == r"\eta\left(x\right)"
assert latex(dirichlet_eta(x)**2) == r"\eta^{2}\left(x\right)"
assert latex(polylog(x, y)) == r"\operatorname{Li}_{x}\left(y\right)"
assert latex(
polylog(x, y)**2) == r"\operatorname{Li}_{x}^{2}\left(y\right)"
assert latex(lerchphi(x, y, n)) == r"\Phi\left(x, y, n\right)"
assert latex(lerchphi(x, y, n)**2) == r"\Phi^{2}\left(x, y, n\right)"
assert latex(elliptic_k(z)) == r"K\left(z\right)"
assert latex(elliptic_k(z)**2) == r"K^{2}\left(z\right)"
assert latex(elliptic_f(x, y)) == r"F\left(x\middle| y\right)"
assert latex(elliptic_f(x, y)**2) == r"F^{2}\left(x\middle| y\right)"
assert latex(elliptic_e(x, y)) == r"E\left(x\middle| y\right)"
assert latex(elliptic_e(x, y)**2) == r"E^{2}\left(x\middle| y\right)"
assert latex(elliptic_e(z)) == r"E\left(z\right)"
#.........这里部分代码省略.........
开发者ID:Ronn3y,项目名称:sympy,代码行数:101,代码来源:test_latex.py
示例14: test_latex_functions
def test_latex_functions():
assert latex(exp(x)) == "e^{x}"
assert latex(exp(1) + exp(2)) == "e + e^{2}"
f = Function('f')
assert latex(f(x)) == '\\operatorname{f}{\\left (x \\right )}'
beta = Function('beta')
assert latex(beta(x)) == r"\beta{\left (x \right )}"
assert latex(sin(x)) == r"\sin{\left (x \right )}"
assert latex(sin(x), fold_func_brackets=True) == r"\sin {x}"
assert latex(sin(2*x**2), fold_func_brackets=True) == \
r"\sin {2 x^{2}}"
assert latex(sin(x**2), fold_func_brackets=True) == \
r"\sin {x^{2}}"
assert latex(asin(x)**2) == r"\operatorname{asin}^{2}{\left (x \right )}"
assert latex(asin(x)**2, inv_trig_style="full") == \
r"\arcsin^{2}{\left (x \right )}"
assert latex(asin(x)**2, inv_trig_style="power") == \
r"\sin^{-1}{\left (x \right )}^{2}"
assert latex(asin(x**2), inv_trig_style="power",
fold_func_brackets=True) == \
r"\sin^{-1} {x^{2}}"
assert latex(factorial(k)) == r"k!"
assert latex(factorial(-k)) == r"\left(- k\right)!"
assert latex(factorial2(k)) == r"k!!"
assert latex(factorial2(-k)) == r"\left(- k\right)!!"
assert latex(binomial(2, k)) == r"{\binom{2}{k}}"
assert latex(FallingFactorial(3, k)) == r"{\left(3\right)}_{\left(k\right)}"
assert latex(RisingFactorial(3, k)) == r"{\left(3\right)}^{\left(k\right)}"
assert latex(floor(x)) == r"\lfloor{x}\rfloor"
assert latex(ceiling(x)) == r"\lceil{x}\rceil"
assert latex(Min(x, 2, x**3)) == r"\min\left(2, x, x^{3}\right)"
assert latex(Max(x, 2, x**3)) == r"\max\left(2, x, x^{3}\right)"
assert latex(Abs(x)) == r"\lvert{x}\rvert"
assert latex(re(x)) == r"\Re{x}"
assert latex(re(x + y)) == r"\Re {\left (x + y \right )}"
assert latex(im(x)) == r"\Im{x}"
assert latex(conjugate(x)) == r"\overline{x}"
assert latex(gamma(x)) == r"\Gamma\left(x\right)"
assert latex(Order(x)) == r"\mathcal{O}\left(x\right)"
assert latex(lowergamma(x, y)) == r'\gamma\left(x, y\right)'
assert latex(uppergamma(x, y)) == r'\Gamma\left(x, y\right)'
assert latex(cot(x)) == r'\cot{\left (x \right )}'
assert latex(coth(x)) == r'\coth{\left (x \right )}'
assert latex(re(x)) == r'\Re{x}'
assert latex(im(x)) == r'\Im{x}'
assert latex(root(x, y)) == r'x^{\frac{1}{y}}'
assert latex(arg(x)) == r'\arg{\left (x \right )}'
assert latex(zeta(x)) == r'\zeta\left(x\right)'
assert latex(zeta(x)) == r"\zeta\left(x\right)"
assert latex(zeta(x)**2) == r"\zeta^{2}\left(x\right)"
assert latex(zeta(x, y)) == r"\zeta\left(x, y\right)"
assert latex(zeta(x, y)**2) == r"\zeta^{2}\left(x, y\right)"
assert latex(dirichlet_eta(x)) == r"\eta\left(x\right)"
assert latex(dirichlet_eta(x)**2) == r"\eta^{2}\left(x\right)"
assert latex(polylog(x, y)) == r"\operatorname{Li}_{x}\left(y\right)"
assert latex(polylog(x, y)**2) == r"\operatorname{Li}_{x}^{2}\left(y\right)"
assert latex(lerchphi(x, y, n)) == r"\Phi\left(x, y, n\right)"
assert latex(lerchphi(x, y, n)**2) == r"\Phi^{2}\left(x, y, n\right)"
assert latex(Ei(x)) == r'\operatorname{Ei}{\left (x \right )}'
assert latex(Ei(x)**2) == r'\operatorname{Ei}^{2}{\left (x \right )}'
assert latex(expint(x, y)**2) == r'\operatorname{E}_{x}^{2}\left(y\right)'
assert latex(Shi(x)**2) == r'\operatorname{Shi}^{2}{\left (x \right )}'
assert latex(Si(x)**2) == r'\operatorname{Si}^{2}{\left (x \right )}'
assert latex(Ci(x)**2) == r'\operatorname{Ci}^{2}{\left (x \right )}'
assert latex(Chi(x)**2) == r'\operatorname{Chi}^{2}{\left (x \right )}'
# Test latex printing of function names with "_"
assert latex(polar_lift(0)) == r"\operatorname{polar\_lift}{\left (0 \right )}"
assert latex(polar_lift(0)**3) == r"\operatorname{polar\_lift}^{3}{\left (0 \right )}"
开发者ID:arunenigma,项目名称:sympy,代码行数:81,代码来源:test_latex.py
示例15: test_factorial2
def test_factorial2():
n = Symbol("n", integer=True)
assert factorial2(-1) == 1
assert factorial2(0) == 1
assert factorial2(7) == 105
assert factorial2(8) == 384
assert factorial2(n).func == factorial2
# The following is exhaustive
tt = Symbol("tt", integer=True, nonnegative=True)
tte = Symbol("tte", even=True, nonnegative=True)
tpe = Symbol("tpe", even=True, positive=True)
tto = Symbol("tto", odd=True, nonnegative=True)
tf = Symbol("tf", integer=True, nonnegative=False)
tfe = Symbol("tfe", even=True, nonnegative=False)
tfo = Symbol("tfo", odd=True, nonnegative=False)
ft = Symbol("ft", integer=False, nonnegative=True)
ff = Symbol("ff", integer=False, nonnegative=False)
fn = Symbol("fn", integer=False)
nt = Symbol("nt", nonnegative=True)
nf = Symbol("nf", nonnegative=False)
nn = Symbol("nn")
assert factorial2(n).is_integer is None
assert factorial2(tt - 1).is_integer
assert factorial2(tte - 1).is_integer
assert factorial2(tpe - 3).is_integer
assert factorial2(tto - 4).is_integer
assert factorial2(tto - 2).is_integer
assert factorial2(tf).is_integer is None
assert factorial2(tfe).is_integer is None
assert factorial2(tfo).is_integer is None
assert factorial2(ft).is_integer is None
assert factorial2(ff).is_integer is None
assert factorial2(fn).is_integer is None
assert factorial2(nt).is_integer is None
assert factorial2(nf).is_integer is None
assert factorial2(nn).is_integer is None
assert factorial2(n).is_positive is None
assert factorial2(tt - 1).is_positive is True
assert factorial2(tte - 1).is_positive is True
assert factorial2(tpe - 3).is_positive is True
assert factorial2(tpe - 1).is_positive is True
assert factorial2(tto - 2).is_positive is True
assert factorial2(tto - 1).is_positive is True
assert factorial2(tf).is_positive is None
assert factorial2(tfe).is_positive is None
assert factorial2(tfo).is_positive is None
assert factorial2(ft).is_positive is None
assert factorial2(ff).is_positive is None
assert factorial2(fn).is_positive is None
assert factorial2(nt).is_positive is None
assert factorial2(nf).is_positive is None
assert factorial2(nn).is_positive is None
assert factorial2(tt).is_even is None
assert factorial2(tt).is_odd is None
assert factorial2(tte).is_even is None
assert factorial2(tte).is_odd is None
assert factorial2(tte + 2).is_even is True
assert factorial2(tpe).is_even is True
assert factorial2(tto).is_odd is True
assert factorial2(tf).is_even is None
assert factorial2(tf).is_odd is None
assert factorial2(tfe).is_even is None
assert factorial2(tfe).is_odd is None
assert factorial2(tfo).is_even is False
assert factorial2(tfo).is_odd is None
开发者ID:guanlongtianzi,项目名称:sympy,代码行数:70,代码来源:test_comb_factorials.py
注:本文中的sympy.factorial2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论