Differentiate composite functions (#530)