I'm really not sure. The original code was if simplify(r[d].diff(y)) == simplify(r[e].diff(x)) . So I didn't change it much