How optimization for machine learning works, part 1