gpt4 book ai didi

python - 有限域上的SymPy多项式

转载 作者:行者123 更新时间:2023-12-03 16:28:34 24 4
gpt4 key购买 nike

import sympy as S 
F = S.FiniteField(101)

当我调用 f = S.poly(y ** 2 - x ** 3 - x - 1,F)时,出现以下错误:

'FiniteField' object has no attribute 'is_commutative'



但是,根据定义,有限域是可交换的!所以我不太确定这个错误是什么意思!

有人遇到过这个吗?您如何在有限域上声明多项式?

最佳答案

is_commutative通常是operators的属性。没有为domains实现(不同于is_numeric等)。
例如

>>> F = sympy.RealField() #returns the same error
>>> f = sympy.poly(y ** 2 - x ** 3 - x - 1, F)

AttributeError: 'RealField' object has no attribute 'is_commutative'

因此, poly将您的位置参数解释为域以外的其他值。要获得 poly(和 factor等)的预期行为,您必须使用 domain (或等效的)kwarg,即:
f = sympy.poly(y ** 2 - x ** 3 - x - 1, domain=F)

关于python - 有限域上的SymPy多项式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29980721/

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