# Generic math notation for minimum/maximum

Where finding the minimum or maximum element of a vector depends on the sign of those values, how can I avoid two time separated description in mathematics?

Is it ok using some convention similar to Optimization problem definition, like below:

let's V be a vector that can have either positive and negative values;

x = sgn(V[argmax|V|]) max(V)


so if the element having maximum absolute value in V is a negative value, the function should calculate minimum rather than maximum.

is it correct in math notation?

In mathematical notation, your formula is $$x = \operatorname{sgn}(v_{\arg\max\{\lvert v_i\rvert : v_i\in V\}}) \max V.$$ Notice that if the most negative element of $$V$$ has a larger magnitude than the most positive element, your formula uses the sign of the most negative element to determine the result, but it does not use the magnitude of the most negative element.
You could fix your original formula by introducing more absolute values, $$x = \operatorname{sgn}(v_{\arg\max\{\lvert v_i\rvert : v_i\in V\}}) \max\{\lvert v_i\rvert : v_i\in V\},$$ but I think a far more elegant solution is just to explicitly list the two cases in which you're interested: $$x = \begin{cases} \max V & \lvert\max V\rvert \geq \lvert\min V\rvert, \\ \min V & \lvert\max V\rvert < \lvert\min V\rvert. \\ \end{cases}$$
Note that you have to decide what to do if the two extreme values in the vector are equal in magnitude and opposite in sign. I chose to set $$x$$ to the positive value in that case, but you could choose differently. You could even make this a third case of your definition with a different behavior from either of the other two cases.
(Note that the case where there are equal and opposite values in $$V$$ is problematic for the formula with $$\arg\max$$, because that formula doesn't say whether to take the positive or negative value in that case.)
• Thank you very much David for your perfect answer, suggestion and reply. As you noticed correctly, I just wanted to see if it is correct to use the convention of -min = max for such case as my example. I take you suggestion. Cheers! – Hamidreza Jun 11 '19 at 12:12