Fixed error in calculation of negative gradient.
Fixed error in calculation of negative gradient.

Changed x[i] -> x[j] in calculation of gradient.
Added several stability enhancing methods

dave77/LinAlg,dave77/LinAlg