Added gradient descent algorithm for exercise 2.4.