sympy mignotte_bound and ring

问题描述 投票:2回答:1

我正在尝试将dup_zz_mignotte_bound(f,K)的结果与其他范围进行比较,但是当我添加dup_zz_mignotte_bound时,我无法在所有范围内使用变量x。例如:

from sympy.polys import ring, ZZ
from sympy.abc import x
from sympy import factor

R, x = ring('x', ZZ)

poly =  x**8 +8*x**7 +47*x**6 +136*x**5 +285*x**4 +171*x**3 - 20*x**2 - 21*x+2

print(factor(poly, x)) # this is an example of a function which is used in other bounds

p = R.dup_zz_mignotte_bound(poly) #Sympys function

print(p)


尝试调用factor()时返回错误。如何使用这两种功能?非常感谢您的宝贵时间!

sympy ring
1个回答
0
投票

使用ring变量创建的poly对象以多项式对象PolyElement形式出现,它不构成sympy中的表达式。

factor但是,需要一个表达式。好消息是您可以轻松地将多项式转换为表达式:

>>> factor(poly.as_expr())
(x**4 + 4*x**3 + 15*x**2 + 3*x - 2)*(x**4 + 4*x**3 + 16*x**2 + 9*x - 1)
© www.soinside.com 2019 - 2024. All rights reserved.