added regularized cost function.
Regularized cost function and gradients.