gpt4 book ai didi

python - Sympy coeff 与 as_independent 不一致

转载 作者:太空宇宙 更新时间:2023-11-04 05:24:36 27 4
gpt4 key购买 nike

我有以下代码片段

import sympy

a = sympy.symbols('a')
b = sympy.symbols('b')
c = sympy.symbols('c')

print((a*b).coeff(c,0))
print((a*b).as_independent(c)[0])

我不明白为什么两个打印语句打印不同的输出。根据 coeff 的文档:

You can select terms independent of x by making n=0; in this case
expr.as_independent(x)[0] is returned (and 0 will be returned instead
of None):

>>> (3 + 2*x + 4*x**2).coeff(x, 0)
3

这是 sympy 中的错误,还是我遗漏了什么?

最佳答案

这是一个错误。我有一个修复它的请求请求 here .

关于python - Sympy coeff 与 as_independent 不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39231911/

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