https://medium.com/@monocosmo77/how-optimal-control-problems-are-used-in-machine-learning-part2-33215144b127