本文整理匯總了Python中sympy.polys.rootoftools.RootSum類的典型用法代碼示例。如果您正苦於以下問題:Python RootSum類的具體用法?Python RootSum怎麽用?Python RootSum使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RootSum類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_RootSum_evalf
def test_RootSum_evalf():
rs = RootSum(x**2 + 1, exp)
assert rs.evalf(n=20, chop=True).epsilon_eq(Float("1.0806046117362794348", 20), Float("1e-20")) == True
assert rs.evalf(n=15, chop=True).epsilon_eq(Float("1.08060461173628", 15), Float("1e-15")) == True
rs = RootSum(x**2 + a, exp, x)
assert rs.evalf() == rs
示例2: test_RootSum_doit
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))
示例3: test_RootSum___new__
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)))