I am using Sage to plot a slope field for x'=-x+80-40*sign(t-6). My coding looks like:
var('t,x') def sign(t): if t > 0: return 1 if t == 0: return 0 if t < 0: return -1 plot_slope_field(-x+80-40*sign(t-6), (t, 0, 5), (y,0,5))
Yet, when I hit evaluate, the error bellow appears
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-1-03195771d047> in <module> 8 return -Integer(1) 9 ---> 10 plot_slope_field(-x+Integer(80)-Integer(40)*sign(t-Integer(6)), (t, Integer(0), Integer(5)), (y,Integer(0),Integer(5))) /home/sc_serv/sage/local/lib/python3.8/site-packages/sage/rings/integer.pyx in sage.rings.integer.Integer.__mul__ (build/cythonized/sage/rings/integer.c:14016)() 1980 return y 1981 -> 1982 return coercion_model.bin_op(left, right, operator.mul) 1983 1984 cpdef _mul_(self, right): /home/sc_serv/sage/local/lib/python3.8/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.bin_op (build/cythonized/sage/structure/coerce.c:11304)() 1246 # We should really include the underlying error. 1247 # This causes so much headache. -> 1248 raise bin_op_exception(op, x, y) 1249 1250 cpdef canonical_coercion(self, x, y): TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '<class 'NoneType'>'
How can I fix this to show my graph?
https://stackoverflow.com/questions/66148543/typeerror-unsupported-operand-parents-for-integer-ring-and-class-none February 11, 2021 at 11:55AM
没有评论:
发表评论