Sympy coeff与as_independent不一致

时间:2016-08-30 15:43:22

标签: python sympy

我有以下代码片段

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])

我不明白为什么两个print语句打印不同的输出。根据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

这是一个同情的错误,还是我错过了什么?

1 个答案:

答案 0 :(得分:1)

这是一个错误。我有一个拉取请求修复它here