regularized cost function