https://www-communication.blogspot.com/2017/11/5-3-constrained-maximum-and-minimum.html