Use integrate instead of sum