Minimum value function

175 Views Asked by At

It's just a very simple question, is there a function defined and that tells you the minumum and maximum value of a list of variables, like: min(4, 3) = 3 min(2, 19) = 2 max(1, 10, 3) = 10 Is that the way to write it? or is there a accepted way of doing it? I'm just a high-schooler and I like playing with math sometimes and I wanted to know if there's a more formal way of writing min() and max(), so don't get mad if it's a very obvious thing to you. Thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

There are two ways to answer this question:


Answer 1: (This was given by Nitin in the comments)

We can write

$$\min(a,b) = \frac{a+b - |b-a|}{2}$$ and $$\max(a,b) = \frac{a+b + |b-a|}{2}$$

To where this first expression comes from, observe that if $b \ge a$, then $|b-a| = b-a$, so $\frac{a+b - |b-a|}{2} = \frac{a+b - (b-a)}{2} = a$, and if $b < a$, then $|b-a| = a-b$, so $\frac{a+b - |b-a|}{2} = \frac{a+b + (b-a)}{2} = b$. To get the second expression, notice that $\min(a,b) + \max(a,b) = a+b$, then rearrange and solve for $\max(a,b)$. If we want to take the maximum over larger (finite) sets of real numbers, we can use the identities

$$\min(a_1, a_2, \cdots a_n) = \min(\min(a_1, a_2, \cdots, a_{n-1}), a_n)$$ $$\max(a_1, a_2, \cdots a_n) = \max(\max(a_1, a_2, \cdots, a_{n-1}), a_n)$$


Answer 2:

The expressions $\min$ and $\max$ are already well defined functions. Many people get the idea in high school that a function is something that you can write out a 'rule' or 'formula' for, but this isn't correct. The definition of a function is an object which takes an input and returns an output (this can be made precise using set-theoretic ideas). The functions $\min$ and $\max$ take as input pairs of (real) numbers (or, if you like, nonempty sets of real numbers), and return the smallest/largest number in the pair (set), respectively.