Ask Your Question

breaks240's profile - activity

2021-02-11 06:58:59 +0200 asked a question TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '<class 'NoneType'>'

Hi all, I am attempting to plot a slope field for the function 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))

BUT EVALUATING THE ABOVE GIVES THE ERROR

TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '<class 'nonetype'="">'

Can anyone help me understand what I am doing wrong?

2021-02-11 06:58:59 +0200 asked a question TypeError: unsupported operand parent(s) for *: 'Integer Ring' and '<class 'NoneType'>'

I keep getting an error when wanting to plot a slope field x' = -x + 80 - 40*sign(t-6)

My code 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))

And the ERROR is:

TypeError                                 Traceback (most recent call last)

<ipython-input-1-5af90de417a8> in <module>
      9 def f(t):
     10     sgn(t-Integer(6))
---> 11 plot_slope_field(-x+Integer(80)-Integer(40)*f(t),(t,Integer(0),Integer(5)),(x,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'>'