本文整理汇总了Python中sympy.rf函数的典型用法代码示例。如果您正苦于以下问题:Python rf函数的具体用法?Python rf怎么用?Python rf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rf函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_special_products
def test_special_products():
# Wallis product
assert product((4*k)**2 / (4*k**2 - 1), (k, 1, n)) == \
4**n*factorial(n)**2/rf(Rational(1, 2), n)/rf(Rational(3, 2), n)
# Euler's product formula for sin
assert product(1 + a/k**2, (k, 1, n)) == \
rf(1 - sqrt(-a), n)*rf(1 + sqrt(-a), n)/factorial(n)**2
开发者ID:A-turing-machine,项目名称:sympy,代码行数:8,代码来源:test_products.py
示例2: test_rf_ff_eval_hiprec
def test_rf_ff_eval_hiprec():
maple = Float('6.9109401292234329956525265438452')
us = ff(18, S(2)/3).evalf(32)
assert abs(us - maple)/us < 1e-31
maple = Float('6.8261540131125511557924466355367')
us = rf(18, S(2)/3).evalf(32)
assert abs(us - maple)/us < 1e-31
maple = Float('34.007346127440197150854651814225')
us = rf(Float('4.4', 32), Float('2.2', 32));
assert abs(us - maple)/us < 1e-31
开发者ID:asmeurer,项目名称:sympy,代码行数:12,代码来源:test_comb_factorials.py
示例3: test_rf_lambdify_mpmath
def test_rf_lambdify_mpmath():
from sympy import lambdify
x, y = symbols('x,y')
f = lambdify((x,y), rf(x, y), 'mpmath')
maple = Float('34.007346127440197')
us = f(4.4, 2.2)
assert abs(us - maple)/us < 1e-15
开发者ID:asmeurer,项目名称:sympy,代码行数:7,代码来源:test_comb_factorials.py
示例4: test_issue_9699
def test_issue_9699():
n, k = symbols('n k', real=True)
x, y = symbols('x, y')
assert combsimp((n + 1)*factorial(n)) == factorial(n + 1)
assert combsimp((x + 1)*factorial(x)/gamma(y)) == gamma(x + 2)/gamma(y)
assert combsimp(factorial(n)/n) == factorial(n - 1)
assert combsimp(rf(x + n, k)*binomial(n, k)) == binomial(n, k)*gamma(k + n + x)/gamma(n + x)
开发者ID:A-turing-machine,项目名称:sympy,代码行数:7,代码来源:test_combsimp.py
示例5: test_simple_products
def test_simple_products():
assert product(2, (k, a, n)) == 2**(n - a + 1)
assert product(k, (k, 1, n)) == factorial(n)
assert product(k**3, (k, 1, n)) == factorial(n)**3
assert product(k + 1, (k, 0, n - 1)) == factorial(n)
assert product(k + 1, (k, a, n - 1)) == rf(1 + a, n - a)
assert product(cos(k), (k, 0, 5)) == cos(1)*cos(2)*cos(3)*cos(4)*cos(5)
assert product(cos(k), (k, 3, 5)) == cos(3)*cos(4)*cos(5)
assert product(cos(k), (k, 1, Rational(5, 2))) != cos(1)*cos(2)
assert isinstance(product(k**k, (k, 1, n)), Product)
assert Product(x**k, (k, 1, n)).variables == [k]
raises(ValueError, lambda: Product(n))
raises(ValueError, lambda: Product(n, k))
raises(ValueError, lambda: Product(n, k, 1))
raises(ValueError, lambda: Product(n, k, 1, 10))
raises(ValueError, lambda: Product(n, (k, 1)))
assert product(1, (n, 1, oo)) == 1 # issue 8301
assert product(2, (n, 1, oo)) == oo
assert product(-1, (n, 1, oo)).func is Product
开发者ID:A-turing-machine,项目名称:sympy,代码行数:25,代码来源:test_products.py
示例6: test_ff_eval_apply
def test_ff_eval_apply():
x, y = symbols('x,y')
n, k = symbols('n k', integer=True)
m = Symbol('m', integer=True, nonnegative=True)
assert ff(nan, y) == nan
assert ff(x, nan) == nan
assert ff(x, y) == ff(x, y)
assert ff(oo, 0) == 1
assert ff(-oo, 0) == 1
assert ff(oo, 6) == oo
assert ff(-oo, 7) == -oo
assert ff(oo, -6) == oo
assert ff(-oo, -7) == oo
assert ff(x, 0) == 1
assert ff(x, 1) == x
assert ff(x, 2) == x*(x - 1)
assert ff(x, 3) == x*(x - 1)*(x - 2)
assert ff(x, 5) == x*(x - 1)*(x - 2)*(x - 3)*(x - 4)
assert ff(x, -1) == 1/(x + 1)
assert ff(x, -2) == 1/((x + 1)*(x + 2))
assert ff(x, -3) == 1/((x + 1)*(x + 2)*(x + 3))
assert ff(100, 100) == factorial(100)
assert ff(2*x**2 - 5*x, 2) == (2*x**2 - 5*x)*(2*x**2 - 5*x - 1)
assert isinstance(ff(2*x**2 - 5*x, 2), Mul)
assert ff(x**2 + 3*x, -2) == 1/((x**2 + 3*x + 1)*(x**2 + 3*x + 2))
assert ff(Poly(2*x**2 - 5*x, x), 2) == Poly(4*x**4 - 28*x**3 + 59*x**2 - 35*x, x)
assert isinstance(ff(Poly(2*x**2 - 5*x, x), 2), Poly)
raises(ValueError, lambda: ff(Poly(2*x**2 - 5*x, x, y), 2))
assert ff(Poly(x**2 + 3*x, x), -2) == 1/(x**4 + 12*x**3 + 49*x**2 + 78*x + 40)
raises(ValueError, lambda: ff(Poly(x**2 + 3*x, x, y), -2))
assert ff(x, m).is_integer is None
assert ff(n, k).is_integer is None
assert ff(n, m).is_integer is True
assert ff(n, k + pi).is_integer is False
assert ff(n, m + pi).is_integer is False
assert ff(pi, m).is_integer is False
assert isinstance(ff(x, x), ff)
assert ff(n, n) == factorial(n)
assert ff(x, k).rewrite(rf) == rf(x - k + 1, k)
assert ff(x, k).rewrite(gamma) == (-1)**k*gamma(k - x) / gamma(-x)
assert ff(n, k).rewrite(factorial) == factorial(n) / factorial(n - k)
assert ff(x, k).rewrite(binomial) == factorial(k) * binomial(x, k)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:56,代码来源:test_comb_factorials.py
示例7: test_simple_products
def test_simple_products():
assert product(2, (k, a, n)) == 2**(n-a+1)
assert product(k, (k, 1, n)) == factorial(n)
assert product(k**3, (k, 1, n)) == factorial(n)**3
assert product(k+1, (k, 0, n-1)) == factorial(n)
assert product(k+1, (k, a, n-1)) == rf(1+a, n-a)
assert product(cos(k), (k, 0, 5)) == cos(1)*cos(2)*cos(3)*cos(4)*cos(5)
assert product(cos(k), (k, 3, 5)) == cos(3)*cos(4)*cos(5)
assert product(cos(k), (k, 1, Rational(5, 2))) == cos(1)*cos(2)
assert isinstance(product(k**k, (k, 1, n)), Product)
开发者ID:Grahack,项目名称:geophar,代码行数:13,代码来源:test_products.py
示例8: test_rsolve_hyper
def test_rsolve_hyper():
assert rsolve_hyper([-1, -1, 1], 0, n) in [
C0*(S.Half - S.Half*sqrt(5))**n + C1*(S.Half + S.Half*sqrt(5))**n,
C1*(S.Half - S.Half*sqrt(5))**n + C0*(S.Half + S.Half*sqrt(5))**n,
]
assert rsolve_hyper([n**2 - 2, -2*n - 1, 1], 0, n) in [
C0*rf(sqrt(2), n) + C1*rf(-sqrt(2), n),
C1*rf(sqrt(2), n) + C0*rf(-sqrt(2), n),
]
assert rsolve_hyper([n**2 - k, -2*n - 1, 1], 0, n) in [
C0*rf(sqrt(k), n) + C1*rf(-sqrt(k), n),
C1*rf(sqrt(k), n) + C0*rf(-sqrt(k), n),
]
assert rsolve_hyper(
[2*n*(n + 1), -n**2 - 3*n + 2, n - 1], 0, n) == C1*factorial(n) + C0*2**n
assert rsolve_hyper(
[n + 2, -(2*n + 3)*(17*n**2 + 51*n + 39), n + 1], 0, n) == None
assert rsolve_hyper([-n - 1, -1, 1], 0, n) == None
assert rsolve_hyper([-1, 1], n, n).expand() == C0 + n**2/2 - n/2
assert rsolve_hyper([-1, 1], 1 + n, n).expand() == C0 + n**2/2 + n/2
assert rsolve_hyper([-1, 1], 3*(n + n**2), n).expand() == C0 + n**3 - n
assert rsolve_hyper([-a, 1],0,n).expand() == C0*a**n
assert rsolve_hyper([-a, 0, 1], 0, n).expand() == (-1)**n*C1*a**(n/2) + C0*a**(n/2)
assert rsolve_hyper([1, 1, 1], 0, n).expand() == \
C0*(-S(1)/2 - sqrt(3)*I/2)**n + C1*(-S(1)/2 + sqrt(3)*I/2)**n
assert rsolve_hyper([1, -2*n/a - 2/a, 1], 0, n) == None
开发者ID:Acebulf,项目名称:sympy,代码行数:38,代码来源:test_recurr.py
示例9: test_rf_eval_apply
def test_rf_eval_apply():
x, y = symbols('x,y')
n, k = symbols('n k', integer=True)
m = Symbol('m', integer=True, nonnegative=True)
assert rf(nan, y) == nan
assert rf(x, nan) == nan
assert rf(x, y) == rf(x, y)
assert rf(oo, 0) == 1
assert rf(-oo, 0) == 1
assert rf(oo, 6) == oo
assert rf(-oo, 7) == -oo
assert rf(oo, -6) == oo
assert rf(-oo, -7) == oo
assert rf(x, 0) == 1
assert rf(x, 1) == x
assert rf(x, 2) == x*(x + 1)
assert rf(x, 3) == x*(x + 1)*(x + 2)
assert rf(x, 5) == x*(x + 1)*(x + 2)*(x + 3)*(x + 4)
assert rf(x, -1) == 1/(x - 1)
assert rf(x, -2) == 1/((x - 1)*(x - 2))
assert rf(x, -3) == 1/((x - 1)*(x - 2)*(x - 3))
assert rf(1, 100) == factorial(100)
assert rf(x**2 + 3*x, 2) == (x**2 + 3*x)*(x**2 + 3*x + 1)
assert isinstance(rf(x**2 + 3*x, 2), Mul)
assert rf(x**3 + x, -2) == 1/((x**3 + x - 1)*(x**3 + x - 2))
assert rf(Poly(x**2 + 3*x, x), 2) == Poly(x**4 + 8*x**3 + 19*x**2 + 12*x, x)
assert isinstance(rf(Poly(x**2 + 3*x, x), 2), Poly)
raises(ValueError, lambda: rf(Poly(x**2 + 3*x, x, y), 2))
assert rf(Poly(x**3 + x, x), -2) == 1/(x**6 - 9*x**5 + 35*x**4 - 75*x**3 + 94*x**2 - 66*x + 20)
raises(ValueError, lambda: rf(Poly(x**3 + x, x, y), -2))
assert rf(x, m).is_integer is None
assert rf(n, k).is_integer is None
assert rf(n, m).is_integer is True
assert rf(n, k + pi).is_integer is False
assert rf(n, m + pi).is_integer is False
assert rf(pi, m).is_integer is False
assert rf(x, k).rewrite(ff) == ff(x + k - 1, k)
assert rf(x, k).rewrite(binomial) == factorial(k)*binomial(x + k - 1, k)
assert rf(n, k).rewrite(factorial) == \
factorial(n + k - 1) / factorial(n - 1)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:52,代码来源:test_comb_factorials.py
示例10: test_rf_eval_apply
def test_rf_eval_apply():
x, y = symbols('x,y')
assert rf(nan, y) == nan
assert rf(x, y) == rf(x, y)
assert rf(oo, 0) == 1
assert rf(-oo, 0) == 1
assert rf(oo, 6) == oo
assert rf(-oo, 7) == -oo
assert rf(oo, -6) == oo
assert rf(-oo, -7) == oo
assert rf(x, 0) == 1
assert rf(x, 1) == x
assert rf(x, 2) == x*(x + 1)
assert rf(x, 3) == x*(x + 1)*(x + 2)
assert rf(x, 5) == x*(x + 1)*(x + 2)*(x + 3)*(x + 4)
assert rf(x, -1) == 1/(x - 1)
assert rf(x, -2) == 1/((x - 1)*(x - 2))
assert rf(x, -3) == 1/((x - 1)*(x - 2)*(x - 3))
assert rf(1, 100) == factorial(100)
开发者ID:FedericoV,项目名称:sympy,代码行数:27,代码来源:test_comb_factorials.py
示例11: test_rf_eval_apply
def test_rf_eval_apply():
x, y = symbols('x,y')
assert rf(nan, y) == nan
assert rf(x, y) == rf(x, y)
assert rf(oo, 0) == 1
assert rf(-oo, 0) == 1
assert rf(oo, 6) == oo
assert rf(-oo, 7) == -oo
assert rf(oo, -6) == oo
assert rf(-oo, -7) == oo
assert rf(x, 0) == 1
assert rf(x, 1) == x
assert rf(x, 2) == x*(x + 1)
assert rf(x, 3) == x*(x + 1)*(x + 2)
assert rf(x, 5) == x*(x + 1)*(x + 2)*(x + 3)*(x + 4)
assert rf(x, -1) == 1/(x - 1)
assert rf(x, -2) == 1/((x - 1)*(x - 2))
assert rf(x, -3) == 1/((x - 1)*(x - 2)*(x - 3))
assert rf(1, 100) == factorial(100)
n = Symbol('n', integer=True)
k = Symbol('k', integer=True)
m = Symbol('m', integer=True, nonnegative=True)
assert rf(x, m).is_integer is None
assert rf(n, k).is_integer is None
assert rf(n, m).is_integer is True
assert rf(n, k + pi).is_integer is False
assert rf(n, m + pi).is_integer is False
assert rf(pi, m).is_integer is False
开发者ID:rahvar,项目名称:sympy,代码行数:37,代码来源:test_comb_factorials.py
示例12: to_sequence
def to_sequence(self):
"""
Finds the recurrence relation in power series expansion
of the function.
Examples
========
>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy.polys.domains import ZZ, QQ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')
>>> HolonomicFunction(Dx - 1, x, 0, [1]).to_sequence()
HolonomicSequence((-1) + (n + 1)Sn, n), u(0) = 1
See Also
========
HolonomicFunction.series
References
==========
hal.inria.fr/inria-00070025/document
"""
dict1 = {}
n = symbols('n', integer=True)
dom = self.annihilator.parent.base.dom
R, _ = RecurrenceOperators(dom.old_poly_ring(n), 'Sn')
for i, j in enumerate(self.annihilator.listofpoly):
listofdmp = j.all_coeffs()
degree = len(listofdmp) - 1
for k in range(degree + 1):
coeff = listofdmp[degree - k]
if coeff == 0:
continue
if i - k in dict1:
dict1[i - k] += (coeff * rf(n - k + 1, i))
else:
dict1[i - k] = (coeff * rf(n - k + 1, i))
sol = []
lower = min(dict1.keys())
upper = max(dict1.keys())
for j in range(lower, upper + 1):
if j in dict1.keys():
sol.append(dict1[j].subs(n, n - lower))
else:
sol.append(S(0))
# recurrence relation
sol = RecurrenceOperator(sol, R)
if not self._have_init_cond:
return HolonomicSequence(sol)
if self.x0 != 0:
return HolonomicSequence(sol)
# computing the initial conditions for recurrence
order = sol.order
all_roots = roots(sol.listofpoly[-1].rep, filter='Z')
all_roots = all_roots.keys()
if all_roots:
max_root = max(all_roots)
if max_root >= 0:
order += max_root + 1
y0 = _extend_y0(self, order)
u0 = []
# u(n) = y^n(0)/factorial(n)
for i, j in enumerate(y0):
u0.append(j / factorial(i))
return HolonomicSequence(sol, u0)
开发者ID:Carreau,项目名称:sympy,代码行数:78,代码来源:holonomic.py
示例13: test_rf_eval_apply
def test_rf_eval_apply():
x, y = symbols("x,y")
n, k = symbols("n k", integer=True)
m = Symbol("m", integer=True, nonnegative=True)
assert rf(nan, y) == nan
assert rf(x, nan) == nan
assert rf(x, y) == rf(x, y)
assert rf(oo, 0) == 1
assert rf(-oo, 0) == 1
assert rf(oo, 6) == oo
assert rf(-oo, 7) == -oo
assert rf(oo, -6) == oo
assert rf(-oo, -7) == oo
assert rf(x, 0) == 1
assert rf(x, 1) == x
assert rf(x, 2) == x * (x + 1)
assert rf(x, 3) == x * (x + 1) * (x + 2)
assert rf(x, 5) == x * (x + 1) * (x + 2) * (x + 3) * (x + 4)
assert rf(x, -1) == 1 / (x - 1)
assert rf(x, -2) == 1 / ((x - 1) * (x - 2))
assert rf(x, -3) == 1 / ((x - 1) * (x - 2) * (x - 3))
assert rf(1, 100) == factorial(100)
assert rf(x ** 2 + 3 * x, 2) == x ** 4 + 8 * x ** 3 + 19 * x ** 2 + 12 * x
assert rf(x ** 3 + x, -2) == 1 / (x ** 6 - 9 * x ** 5 + 35 * x ** 4 - 75 * x ** 3 + 94 * x ** 2 - 66 * x + 20)
assert rf(x, m).is_integer is None
assert rf(n, k).is_integer is None
assert rf(n, m).is_integer is True
assert rf(n, k + pi).is_integer is False
assert rf(n, m + pi).is_integer is False
assert rf(pi, m).is_integer is False
assert rf(x, k).rewrite(ff) == ff(x + k - 1, k)
assert rf(x, k).rewrite(binomial) == factorial(k) * binomial(x + k - 1, k)
assert rf(n, k).rewrite(factorial) == factorial(n + k - 1) / factorial(n - 1)
开发者ID:scopatz,项目名称:sympy,代码行数:44,代码来源:test_comb_factorials.py
示例14: test_F1
def test_F1():
assert rf(x, 3) == x*(1 + x)*(2 + x)
开发者ID:batya239,项目名称:sympy,代码行数:2,代码来源:test_wester.py
示例15: test_rational_products
def test_rational_products():
assert product(1 + 1/k, (k, 1, n)) == rf(2, n)/factorial(n)
开发者ID:A-turing-machine,项目名称:sympy,代码行数:2,代码来源:test_products.py
示例16: test_gammasimp
def test_gammasimp():
R = Rational
# was part of test_combsimp_gamma() in test_combsimp.py
assert gammasimp(gamma(x)) == gamma(x)
assert gammasimp(gamma(x + 1)/x) == gamma(x)
assert gammasimp(gamma(x)/(x - 1)) == gamma(x - 1)
assert gammasimp(x*gamma(x)) == gamma(x + 1)
assert gammasimp((x + 1)*gamma(x + 1)) == gamma(x + 2)
assert gammasimp(gamma(x + y)*(x + y)) == gamma(x + y + 1)
assert gammasimp(x/gamma(x + 1)) == 1/gamma(x)
assert gammasimp((x + 1)**2/gamma(x + 2)) == (x + 1)/gamma(x + 1)
assert gammasimp(x*gamma(x) + gamma(x + 3)/(x + 2)) == \
(x + 2)*gamma(x + 1)
assert gammasimp(gamma(2*x)*x) == gamma(2*x + 1)/2
assert gammasimp(gamma(2*x)/(x - S(1)/2)) == 2*gamma(2*x - 1)
assert gammasimp(gamma(x)*gamma(1 - x)) == pi/sin(pi*x)
assert gammasimp(gamma(x)*gamma(-x)) == -pi/(x*sin(pi*x))
assert gammasimp(1/gamma(x + 3)/gamma(1 - x)) == \
sin(pi*x)/(pi*x*(x + 1)*(x + 2))
assert gammasimp(factorial(n + 2)) == gamma(n + 3)
assert gammasimp(binomial(n, k)) == \
gamma(n + 1)/(gamma(k + 1)*gamma(-k + n + 1))
assert powsimp(gammasimp(
gamma(x)*gamma(x + S(1)/2)*gamma(y)/gamma(x + y))) == \
2**(-2*x + 1)*sqrt(pi)*gamma(2*x)*gamma(y)/gamma(x + y)
assert gammasimp(1/gamma(x)/gamma(x - S(1)/3)/gamma(x + S(1)/3)) == \
3**(3*x - S(3)/2)/(2*pi*gamma(3*x - 1))
assert simplify(
gamma(S(1)/2 + x/2)*gamma(1 + x/2)/gamma(1 + x)/sqrt(pi)*2**x) == 1
assert gammasimp(gamma(S(-1)/4)*gamma(S(-3)/4)) == 16*sqrt(2)*pi/3
assert powsimp(gammasimp(gamma(2*x)/gamma(x))) == \
2**(2*x - 1)*gamma(x + S(1)/2)/sqrt(pi)
# issue 6792
e = (-gamma(k)*gamma(k + 2) + gamma(k + 1)**2)/gamma(k)**2
assert gammasimp(e) == -k
assert gammasimp(1/e) == -1/k
e = (gamma(x) + gamma(x + 1))/gamma(x)
assert gammasimp(e) == x + 1
assert gammasimp(1/e) == 1/(x + 1)
e = (gamma(x) + gamma(x + 2))*(gamma(x - 1) + gamma(x))/gamma(x)
assert gammasimp(e) == (x**2 + x + 1)*gamma(x + 1)/(x - 1)
e = (-gamma(k)*gamma(k + 2) + gamma(k + 1)**2)/gamma(k)**2
assert gammasimp(e**2) == k**2
assert gammasimp(e**2/gamma(k + 1)) == k/gamma(k)
a = R(1, 2) + R(1, 3)
b = a + R(1, 3)
assert gammasimp(gamma(2*k)/gamma(k)*gamma(k + a)*gamma(k + b))
3*2**(2*k + 1)*3**(-3*k - 2)*sqrt(pi)*gamma(3*k + R(3, 2))/2
# issue 9699
assert gammasimp((x + 1)*factorial(x)/gamma(y)) == gamma(x + 2)/gamma(y)
assert gammasimp(rf(x + n, k)*binomial(n, k)) == gamma(n + 1)*gamma(k + n
+ x)/(gamma(k + 1)*gamma(n + x)*gamma(-k + n + 1))
A, B = symbols('A B', commutative=False)
assert gammasimp(e*B*A) == gammasimp(e)*B*A
# check iteration
assert gammasimp(gamma(2*k)/gamma(k)*gamma(-k - R(1, 2))) == (
-2**(2*k + 1)*sqrt(pi)/(2*((2*k + 1)*cos(pi*k))))
assert gammasimp(
gamma(k)*gamma(k + R(1, 3))*gamma(k + R(2, 3))/gamma(3*k/2)) == (
3*2**(3*k + 1)*3**(-3*k - S.Half)*sqrt(pi)*gamma(3*k/2 + S.Half)/2)
# issue 6153
assert gammasimp(gamma(S(1)/4)/gamma(S(5)/4)) == 4
# was part of test_combsimp() in test_combsimp.py
assert gammasimp(binomial(n + 2, k + S(1)/2)) == gamma(n + 3)/ \
(gamma(k + S(3)/2)*gamma(-k + n + S(5)/2))
assert gammasimp(binomial(n + 2, k + 2.0)) == \
gamma(n + 3)/(gamma(k + 3.0)*gamma(-k + n + 1))
# issue 11548
assert gammasimp(binomial(0, x)) == sin(pi*x)/(pi*x)
e = gamma(n + S(1)/3)*gamma(n + S(2)/3)
assert gammasimp(e) == e
assert gammasimp(gamma(4*n + S(1)/2)/gamma(2*n - S(3)/4)) == \
2**(4*n - S(5)/2)*(8*n - 3)*gamma(2*n + S(3)/4)/sqrt(pi)
i, m = symbols('i m', integer = True)
e = gamma(exp(i))
assert gammasimp(e) == e
e = gamma(m + 3)
assert gammasimp(e) == e
e = gamma(m + 1)/(gamma(i + 1)*gamma(-i + m + 1))
assert gammasimp(e) == e
p = symbols("p", integer=True, positive=True)
assert gammasimp(gamma(-p+4)) == gamma(-p+4)
开发者ID:asmeurer,项目名称:sympy,代码行数:98,代码来源:test_gammasimp.py
示例17: Symbol
n = Symbol("n", positive=True, integer=True)
k = Symbol("k", integer=True)
# binomialpoly = implemented_function(Function('(x+y)^n'), lambda n: (x+y)**n)
# binomialpoly_n = lambdify(n, binomialpoly(n))
binomialpoly = (x + y) ** n
binomialpolyexpand = Sum(binomial(n, k) * x ** k * y ** (n - k), (k, 0, n))
binomialpoly.subs(n, 1) == binomialpolyexpand.subs(n, 1).doit() # True
binomialpoly.subs(n, 2).expand() == binomialpolyexpand.subs(n, 2).doit() # True
binomialpoly.subs(n, 3).expand() == binomialpolyexpand.subs(n, 3).doit() # True
binomialpoly.subs(n, 4).expand() == binomialpolyexpand.subs(n, 4).doit() # True
# rising factorial
a, q = symbols("a q")
# a_n = Product(a+k,(k,0,n-1))
a_n = rf(a, n)
aq_n = Product(Rat(1) - a * q ** k, (k, 0, n - 1))
# e.g. aq_n.subs(n,3).doit()
# Hermite polynomials
HermiteF = factorial(n) * (Rat(-1)) ** k * (Rat(2) * x) ** (n - Rat(2) * k) / (factorial(n - Rat(2) * k) * factorial(k))
HermiteP = Sum(HermiteF, (k, 0, floor(n / 2)))
hermite_poly(1, x) == HermiteP.subs(n, 1).doit() # True
hermite_poly(2, x) == HermiteP.subs(n, 2).doit() # True
hermite_poly(3, x) == HermiteP.subs(n, 3).doit() # True
hermite_poly(4, x) == HermiteP.subs(n, 4).doit() # True
(HermiteF.subs(n, n + 1) / HermiteF).simplify() # 2*x*(n + 1)/(-2*k + n + 1)
(HermiteF.subs(k, k + 1) / HermiteF).simplify() # -(2*k - n)*(2*k - n + 1)/(4*x**2*(k + 1))
开发者ID:ernestyalumni,项目名称:qSApoly,代码行数:30,代码来源:hypergeo.py
注:本文中的sympy.rf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论