Implement the aradient descent algorithm