本文整理汇总了Python中sympy.polys.Poly.length方法的典型用法代码示例。如果您正苦于以下问题:Python Poly.length方法的具体用法?Python Poly.length怎么用?Python Poly.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.polys.Poly
的用法示例。
在下文中一共展示了Poly.length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: roots
# 需要导入模块: from sympy.polys import Poly [as 别名]
# 或者: from sympy.polys.Poly import length [as 别名]
#.........这里部分代码省略.........
if root in result:
result[root] += k
else:
result[root] = k
def _try_decompose(f):
"""Find roots using functional decomposition. """
factors = f.decompose()
result, g = {}, factors[0]
for h, i in g.sqf_list()[1]:
for r in _try_heuristics(h):
_update_dict(result, r, i)
for factor in factors[1:]:
last, result = result.copy(), {}
for last_r, i in last.iteritems():
g = factor - Poly(last_r, x)
for h, j in g.sqf_list()[1]:
for r in _try_heuristics(h):
_update_dict(result, r, i*j)
return result
def _try_heuristics(f):
"""Find roots using formulas and some tricks. """
if f.is_ground:
return []
if f.is_monomial:
return [S(0)]*f.degree()
if f.length() == 2:
if f.degree() == 1:
return map(cancel, roots_linear(f))
else:
return roots_binomial(f)
result = []
for i in [S(-1), S(1)]:
if f.eval(i).expand().is_zero:
f = f.exquo(Poly(x-1, x))
result.append(i)
break
n = f.degree()
if n == 1:
result += map(cancel, roots_linear(f))
elif n == 2:
result += map(cancel, roots_quadratic(f))
elif n == 3 and flags.get('cubics', True):
result += roots_cubic(f)
elif n == 4 and flags.get('quartics', True):
result += roots_quartic(f)
return result
if f.is_monomial == 1:
if f.is_ground:
if multiple:
return []
else:
return {}