Delegate for a scalar objective that also returns its gradient.