本文整理汇总了Python中sympy.polys.Poly.nroots方法的典型用法代码示例。如果您正苦于以下问题:Python Poly.nroots方法的具体用法?Python Poly.nroots怎么用?Python Poly.nroots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.polys.Poly
的用法示例。
在下文中一共展示了Poly.nroots方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_nroots2
# 需要导入模块: from sympy.polys import Poly [as 别名]
# 或者: from sympy.polys.Poly import nroots [as 别名]
def test_nroots2():
p = Poly(x**5+3*x+1, x)
roots = p.nroots(n=3)
# The order of roots matters. The roots are ordered by their real
# components (if they agree, then by their imaginary components).
assert [str(r) for r in roots] == \
['-0.839 - 0.944*I', '-0.839 + 0.944*I', '-0.332',
'1.01 - 0.937*I', '1.01 + 0.937*I']
roots = p.nroots(n=5)
assert [str(r) for r in roots] == \
['-0.83907 - 0.94385*I', '-0.83907 + 0.94385*I',
'-0.33199', '1.0051 - 0.93726*I', '1.0051 + 0.93726*I']
示例2: test_nroots2
# 需要导入模块: from sympy.polys import Poly [as 别名]
# 或者: from sympy.polys.Poly import nroots [as 别名]
def test_nroots2():
p = Poly(x ** 5 + 3 * x + 1, x)
roots = p.nroots(n=3)
# The order of roots matters. The roots are ordered by their real
# components (if they agree, then by their imaginary components),
# with real roots appearing first.
assert [str(r) for r in roots] == [
"-0.332",
"-0.839 - 0.944*I",
"-0.839 + 0.944*I",
"1.01 - 0.937*I",
"1.01 + 0.937*I",
]
roots = p.nroots(n=5)
assert [str(r) for r in roots] == [
"-0.33199",
"-0.83907 - 0.94385*I",
"-0.83907 + 0.94385*I",
"1.0051 - 0.93726*I",
"1.0051 + 0.93726*I",
]