Function to calculate gradient descient in simple linear regression