The following are some handy formulas for computing the gradient or Jacobian of a (vector) function expressed in terms of matrices: