minmax function

AD-compatible minimum and maximum functions