本文整理汇总了Python中sympy.polys.rootoftools.RootSum.doit方法的典型用法代码示例。如果您正苦于以下问题:Python RootSum.doit方法的具体用法?Python RootSum.doit怎么用?Python RootSum.doit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.polys.rootoftools.RootSum
的用法示例。
在下文中一共展示了RootSum.doit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_RootSum_doit
# 需要导入模块: from sympy.polys.rootoftools import RootSum [as 别名]
# 或者: from sympy.polys.rootoftools.RootSum import doit [as 别名]
def test_RootSum_doit():
rs = RootSum(x**2 + 1, exp)
assert isinstance(rs, RootSum) is True
assert rs.doit() == exp(-I) + exp(I)
rs = RootSum(x**2 + a, exp, x)
assert isinstance(rs, RootSum) is True
assert rs.doit() == exp(-sqrt(-a)) + exp(sqrt(-a))
示例2: test_RootSum___new__
# 需要导入模块: from sympy.polys.rootoftools import RootSum [as 别名]
# 或者: from sympy.polys.rootoftools.RootSum import doit [as 别名]
def test_RootSum___new__():
f = x**3 + x + 3
g = Lambda(r, log(r*x))
s = RootSum(f, g)
rootofs = sum(log(RootOf(f, i)*x) for i in (0, 1, 2))
assert isinstance(s, RootSum) == True
assert s.doit() == rootofs
assert RootSum(f**2, g) == 2*RootSum(f, g)
assert RootSum(f**2, g).doit() == 2*rootofs
assert RootSum((x - 7)*f**3, g) == log(7*x) + 3*RootSum(f, g)
assert RootSum((x - 7)*f**3, g).doit() == log(7*x) + 3*rootofs
# Issue 2472
assert hash(RootSum((x - 7)*f**3, g)) == hash(log(7*x) + 3*RootSum(f, g))
raises(MultivariatePolynomialError, "RootSum(x**3 + x + y)")
raises(ValueError, "RootSum(x**2 + 3, lambda x: x)")
assert RootSum(f, exp) == RootSum(f, Lambda(x, exp(x)))
assert RootSum(f, log) == RootSum(f, Lambda(x, log(x)))
assert isinstance(RootSum(f, auto=False), RootSum) == True
assert RootSum(f) == 0
assert RootSum(f, Lambda(x, x)) == 0
assert RootSum(f, Lambda(x, x**2)) == -2
assert RootSum(f, Lambda(x, 1)) == 3
assert RootSum(f, Lambda(x, 2)) == 6
assert RootSum(f, auto=False).is_commutative == True
assert RootSum(f, Lambda(x, 1/(x + x**2))) == S(11)/3
assert RootSum(f, Lambda(x, y/(x + x**2))) == S(11)/3*y
assert RootSum(x**2 - 1, Lambda(x, 3*x**2), x) == 6
assert RootSum(x**2 - y, Lambda(x, 3*x**2), x) == 6*y
assert RootSum(x**2 - 1, Lambda(x, z*x**2), x) == 2*z
assert RootSum(x**2 - y, Lambda(x, z*x**2), x) == 2*z*y
assert RootSum(x**2 - 1, Lambda(x, exp(x)), quadratic=True) == exp(-1) + exp(1)
assert RootSum(x**3 + a*x + a**3, tan, x) == RootSum(x**3 + x + 1, Lambda(x, tan(a*x)))
assert RootSum(a**3*x**3 + a*x + 1, tan, x) == RootSum(x**3 + x + 1, Lambda(x, tan(x/a)))