If a piecewise constant function is integrated, the result is okay, if 2 integrals are nested, that's okay too, but 3 times the result is 'nan' which it shouldn't be: from sympy import * a1, a2, a3 = ...