completed single variable gradient descent