completed implementaion of gradient descent (normal equations)