2016-08-30 29 views
2

一致我的代碼Sympy _係數不as_independent

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中的錯誤,還是我錯過了什麼?

+0

這看起來像一個錯誤。你可以[打開一個問題](https://github.com/sympy/sympy/issues/new)? – asmeurer

+0

我已經爲此[這裏](https://github.com/sympy/sympy/pull/11590)做了一個修復。 – asmeurer

回答

1

這是一個錯誤。我有一個請求修復here