当前位置: 首页>>代码示例>>Python>>正文


Python Product.doit方法代码示例

本文整理汇总了Python中sympy.Product.doit方法的典型用法代码示例。如果您正苦于以下问题:Python Product.doit方法的具体用法?Python Product.doit怎么用?Python Product.doit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.Product的用法示例。


在下文中一共展示了Product.doit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_simple_products

# 需要导入模块: from sympy import Product [as 别名]
# 或者: from sympy.Product import doit [as 别名]
def test_simple_products():
    assert Product(S.NaN, (x, 1, 3)) is S.NaN
    assert product(S.NaN, (x, 1, 3)) is S.NaN
    assert Product(x, (n, a, a)).doit() == x
    assert Product(x, (x, a, a)).doit() == a
    assert Product(x, (y, 1, a)).doit() == x**a
    lo, hi = 1, 2
    s1 = Product(n, (n, lo, hi))
    s2 = Product(n, (n, hi, lo))
    assert s1 != s2
    assert s1.doit() == s2.doit() == 2
    lo, hi = x, x + 1
    s1 = Product(n, (n, lo, hi))
    s2 = Product(n, (n, hi, lo))
    assert s1 != s2
    assert s1.doit() == s2.doit() == x*(x + 1)
    assert Product(Integral(2*x, (x, 1, y)) + 2*x, (x, 1, 2)).doit() == \
        (y**2 + 1)*(y**2 + 3)
    assert product(2, (n, a, b)) == 2**(b - a + 1)
    assert product(n, (n, 1, b)) == factorial(b)
    assert product(n**3, (n, 1, b)) == factorial(b)**3
    assert product(3**(2 + n), (n, a, b)) \
        == 3**(2*(1 - a + b) + b/2 + (b**2)/2 + a/2 - (a**2)/2)
    assert product(cos(n), (n, 3, 5)) == cos(3)*cos(4)*cos(5)
    assert product(cos(n), (n, x, x + 2)) == cos(x)*cos(x + 1)*cos(x + 2)
    assert isinstance(product(cos(n), (n, x, x + S.Half)), Product)
    # If Product managed to evaluate this one, it most likely got it wrong!
    assert isinstance(Product(n**n, (n, 1, b)), Product)
开发者ID:Maihj,项目名称:sympy,代码行数:30,代码来源:test_sums_products.py

示例2: test_wallis_product

# 需要导入模块: from sympy import Product [as 别名]
# 或者: from sympy.Product import doit [as 别名]
def test_wallis_product():
    # Wallis product, given in two different forms to ensure that Product
    # can factor simple rational expressions
    A = Product(4*n**2 / (4*n**2 - 1), (n, 1, b))
    B = Product((2*n)*(2*n)/(2*n - 1)/(2*n + 1), (n, 1, b))
    R = pi*gamma(b + 1)**2/(2*gamma(b + S(1)/2)*gamma(b + S(3)/2))
    assert simplify(A.doit()) == R
    assert simplify(B.doit()) == R
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:10,代码来源:test_sums_products.py

示例3: test_wallis_product

# 需要导入模块: from sympy import Product [as 别名]
# 或者: from sympy.Product import doit [as 别名]
def test_wallis_product():
    # Wallis product, given in two different forms to ensure that Product
    # can factor simple rational expressions
    A = Product(4*n**2 / (4*n**2 - 1), (n, 1, b))
    B = Product((2*n)*(2*n)/(2*n - 1)/(2*n + 1), (n, 1, b))
    half = Rational(1, 2)
    R = pi/2 * factorial(b)**2 / factorial(b - half) / factorial(b + half)
    assert simplify(A.doit()) == R
    assert simplify(B.doit()) == R
开发者ID:JoenyBui,项目名称:sympy,代码行数:11,代码来源:test_sums_products.py

示例4: test_conjugate_transpose

# 需要导入模块: from sympy import Product [as 别名]
# 或者: from sympy.Product import doit [as 别名]
def test_conjugate_transpose():
    p = Product(x**k, (k, 1, 3))
    assert p.adjoint().doit() == p.doit().adjoint()
    assert p.conjugate().doit() == p.doit().conjugate()
    assert p.transpose().doit() == p.doit().transpose()

    A, B = symbols("A B", commutative=False)
    p = Product(A*B**k, (k, 1, 3))
    assert p.adjoint().doit() == p.doit().adjoint()
    assert p.conjugate().doit() == p.doit().conjugate()
    assert p.transpose().doit() == p.doit().transpose()
开发者ID:A-turing-machine,项目名称:sympy,代码行数:13,代码来源:test_products.py

示例5: test_issue_9983

# 需要导入模块: from sympy import Product [as 别名]
# 或者: from sympy.Product import doit [as 别名]
def test_issue_9983():
    n = Symbol('n', integer=True, positive=True)
    p = Product(1 + 1/n**(S(2)/3), (n, 1, oo))
    assert p.is_convergent() is S.false
    assert product(1 + 1/n**(S(2)/3), (n, 1, oo)) == p.doit()
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:7,代码来源:test_products.py


注:本文中的sympy.Product.doit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。