Simplifying and differentiating expressions