gpt4 book ai didi

python - SymPy 是否失去了除以多个多项式的功能?

转载 作者:太空宇宙 更新时间:2023-11-03 14:00:53 25 4
gpt4 key购买 nike

SymPy 新手,正在尝试除法多项式。目前,我正在运行带有 SymPy 1.1.1(安装了 pip)的 Python 3.6.4。浏览他们的文档后,我发现他们的 0.6.7 documentation page以下有用的示例:

Another option is division by multiple polynomials at the same time. In general, the output is not unique and depends on the order of the divisors and the given monomial order (if specified).

>>> f = x*y + y*z + z*x
>>> g1 = x + 1
>>> g2 = 2*y + 1
>>> q, r = div(f, [g1, g2], x, y, z)
>>> q
z
[y + z, -1/2 + -]
2
>>> r
3*z
1/2 - ---
2

不过,这个功能,至少在1.1.1 documentation page中是这样的。是不存在的。而且,更重要的是,如果我尝试在 1.1.1 上尝试类似的操作,则会收到以下错误:

>>> f = x*y + y*z + z*x
>>> g1 = x + 1
>>> g2 = 2*y + 1
>>> q, r = div(f, [g1, g2], x, y, z)
Traceback (most recent call last):
File "C:\[...]\Python\Python36\lib\site-packages\sympy\polys\polytools.py", line 4659, in div
(F, G), opt = parallel_poly_from_expr((f, g), *gens, **args)
File "C:\[...]\Python\Python36\lib\site-packages\sympy\polys\polytools.py", line 4266, in parallel_poly_from_expr
return _parallel_poly_from_expr(exprs, opt)
File "C:\[...]\Python\Python36\lib\site-packages\sympy\polys\polytools.py", line 4312, in _parallel_poly_from_expr
raise PolificationFailed(opt, origs, exprs, True)
sympy.polys.polyerrors.PolificationFailed: can't construct polynomials from x*y + x*z + y*z, [x + 1, 2*y + 1]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\[...]\Python\Python36\lib\site-packages\sympy\polys\polytools.py", line 4661, in div
raise ComputationFailed('div', 2, exc)
sympy.polys.polyerrors.ComputationFailed: div(x*y + x*z + y*z, [x + 1, 2*y + 1]) failed without generators

我非常怀疑这个功能已被删除,因为这是一个非常重要的功能,特别是对于仿射变量和 Groebner 基础分析(我正在研究的主题)

有人可以给我指点 SymPy 的工作示例吗?

最佳答案

现在可以通过函数 reduced 使用此功能。使用示例中的 f、g1、g2,

>>> reduced(f, [g1, g2], x, y, z)
([y + z, z/2 - 1/2], -3*z/2 + 1/2)

关于python - SymPy 是否失去了除以多个多项式的功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49244320/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com