我正在尝试根据以下方程式制作“ matplotlib”图:q(x)=(x ** 2)/(x + 1)
我尝试了以下代码:
def r(x):
return (x*x) / (x+1)
while x<= -2 | x >= 0:
pylab.plot(x, r(x), color = 'r--')
哪个告诉我错误:
TypeError Traceback (most recent call last)
<ipython-input-14-387fb2375bb1> in <module>
2 return (x*x) / (x+1)
3
----> 4 while x<= -2 | x >= 0:
5 pylab.plot(x, r(x), color = 'r--')
TypeError: ufunc 'bitwise_or' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
我是python机器学习的新手,所以我对如何调试它知之甚少。
感谢您的帮助!