Calculus of variations and optimal control for generalized functions. (March 2022)