Finished cost function.
Finished gradient.
Added regularization.
Added last functions.