Finding the derivative of a composite function