I know that $\max(a,b) = \frac{a + b + |a-b|}2$ What I want is to formulate a similar equation generalizing larger sets: $max(a,b,c)$, $\max(a,b,c,d)$ etc. I tried doing the algebra for $\max(a,max(b,c))$ to see if a pattern would emerge but I'm having trouble simplifying.
I don't have a great understanding of algebraic transformations over absolute values. What I'm really hoping for is that there is already a known generalization for max or min of a set. Is there such an equation?
For context, this isn't academic. I'm trying to write a formula for a spreadsheet that will find me the max or min of each row of a matrix of unknown dimensions. It's not good enough to just copy a formula for each row. In Google Sheets/Excel you can do this using the function: ARRAYFORMULA which repeats a formula inside it over each member of an array, but only for scalar functions (IE I can't use the built in MAX and MIN functions in sheets). So for example, on a 2-column matrix of any length my formula is: ARRAYFORMULA((A:A+B:B±abs(A:A-B:B))/2).