Add regularized cost function.