A generalized multidirectional mean value inequality and dynamic optimization. (3rd July 2019)