Differentiation and the gradient function