지금 SymPy
을 배우고 있습니다. 여기에 내가 가진 문제 :Sympy TypeError : sympy를 사용할 때 Relational의 진리 값을 결정할 수 없습니다.
x = symbols('x',real=True)
h = symbols('h',real=True)
f = symbols('f',cls=Function)
sym_dexpr = f_diff.subs(f(x), x*exp(-x**2)).doit()
f_diff = f(x).diff(x,1)
expr_diff = as_finite_diff(f_diff, [x, x-h,x-2*h,x-3*h])
w=Wild('w')
c=Wild('c')
patterns = [arg.match(c*f(w)) for arg in expr_diff.args]
coefficients = [t[c] for t in sorted(patterns, key=lambda t:t[w])]
print(coefficients)
는하지만 오류 다음 가지고 : 나는 Windows 7
, Python 3.5.2
및 Anaconda 3
을 사용하고
TypeError Traceback (most recent call last) in() ----> 1 coefficients = [t[c] for t in sorted(patterns, key=lambda t:t[w])] 2 print(coefficients)
C:\Program Files\Anaconda3\lib\site-packages\sympy\core\relational.py in nonzero(self) 193 194 def nonzero(self): --> 195 raise TypeError("cannot determine truth value of Relational") 196 197 bool = nonzero
TypeError: cannot determine truth value of Relational
.
감사합니다.