# Prove that $\max(x, \max(y, z)) = \max(\max(x, y), z)$

I'm doing my first steps in math proofs, therefore it seems a bit difficult to me to do them, so right now I have difficulties with the following:

Let's define the function $$\max(x, y)$$ as follows: if $$x < y$$, then $$\max(x, y) = y;$$ else, $$\max(x, y) = x$$. For example, $$\max(1, 3) = 3$$, $$\max(2, 2) = 2$$, and $$\max(-π, 137) = 137$$. Prove that the following holds for any $$x$$, $$y$$, and $$z$$: $$\max(x, \max(y, z)) = \max(\max(x, y), z)$$

What I have already tried. My first suggestion was to reach out to the definition of max, so that I can clarify what exactly the left side $$\max(x, \max(y, z))$$ means. The definition says that there are two cases to consider: when $$x < \max(x, y)$$ and when $$x \geq \max(x, y)$$. After this I got stuck, because the further assumptions seem branched (e.g. in the case $$x < \max(x, y)$$ we want to consider two cases of the right side expression and etc).

Another approach I was thinking about is to consider all the possible cases (e.g. $$x \leq y \leq z$$, then $$x \leq z \leq y$$ etc) what seems odd and I guess there are more sophisticated ways to prove that (but I may be wrong).

Could you please give me any hints to problem which would lead me to more elegant proofs of this $$\max(x, \max(y, z)) = \max(\max(x, y), z)$$ if there are any? By the way, is it important how you actually prove a theorem? Or is the result only important?

$$\text{cycle}[\text{max}(x, \text{max}(y,z))]=\text{max}(x,y,z)$$. Because this works like a filter which first filters out greater among two members, and then compare it to another and then filters out the greatest.

This means both of your expression

$$\text{max}(x, \text{max}(y,z)) =\text{max}(x,y,z)$$

$$\text{max}(z, \text{max}(x,y)) = \text{max}(x,y,z)$$

• Yeah, I see the idea, because this is what comes to my mind when I'm trying to understand this statement intuitively. So yeah, this is pretty obvious, but are you sure we can say like this works like a filter which first filters out greater among two members in the formulation of the proof? – E. Shcherbo May 7 at 5:46
• I am sure. If there are both max or both min they are obviously filters out the max or min respectively. – Alapan Das May 7 at 6:03
• You may think those like three pillars having bases at $-\infty$ and having different heights kept from left to right, and one can see only two pillers on the left. So, in the innermost $\text{max}$ one jumps on the top of the higher Piller among first 2. And then he remains there if the leftmost is equal or shorter than his present piller otherwise jumps if that is taller. So, reaches on top of the highest piller. – Alapan Das May 7 at 6:10
• I understand you, thanks! How can you write this formally? – E. Shcherbo May 7 at 12:25

Your second idea for a proof is quite sensible, and it is what I would do. It's six cases, which is relatively large for a proof by cases, but each one is just a line long and your reader's eyes will glaze over after the second one anyways.

• One more thing I'm worrying about the second approach is a definition of the $\max$ function. It says nothing about the case when the first argument is less than the second. I mean for the case $x \leq y \leq z$ we probably will think about the result of $\max(y, z)$. So by the definition we see that $\max(y, z) = y$ if $y < z$, but it says nothing about the case when $y \leq z$. Could you please explain what I'm getting wrong? – E. Shcherbo May 7 at 6:09