I have the following code and error message. Something I am doing seems to be messing up the % function in the hb function. I'm not really sure what or how to fix it. Any ideas?
def h(n):
if (n % 4 >= 0) and (n % 4 < 1):
k = 1
else:
k = 0
return k
def hb(n):
if (((n/4) % 2) >= 0) and (((n/4) % 2) < 1):
k = -1*h(n)
else:
k = h(n)
return k
def dalembert(y,t):
x = 0.5*hb(y-t)+0.5*hb(y+t)
return x
import numpy as np
box1 = np.array([1,2,6,10,20])
for i in range(len(box1)):
g=Graphics()
g += plot(dalembert(x,box1[i]), (x, 0, 4), color='blue')
g.show()
Error in lines 18-21 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags) in namespace, locals File "", line 3, in File "", line 2, in dalembert File "", line 2, in hb File "sage/structure/element.pyx", line 1925, in sage.structure.element.Element.mod (build/cythonized/sage/structure/element.c:13956) return coercion_model.bin_op(left, right, mod) File "sage/structure/coerce.pyx", line 1182, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (build/cythonized/sage/structure/coerce.c:9827) return PyObject_CallObject(op, xy) File "sage/structure/element.pyx", line 1923, in sage.structure.element.Element.mod (build/cythonized/sage/structure/element.c:13921) return (left).mod(right) File "sage/structure/element.pyx", line 1958, in sage.structure.element.Element.mod (build/cythonized/sage/structure/element.c:14242) raise bin_op_exception('%', self, other) TypeError: unsupported operand parent(s) for %: 'Symbolic Ring' and 'Symbolic Ring'