# Thread: A max function of 2 variables max(a,b)

1. ## A max function of 2 variables max(a,b)

The max function is a function of 2 variables and is defined as follows

max(x,y) = x if x is greater or equal to y or it's = y if x is less than y

How would I go about expressing this piecewise function in one line using an absolute value function?

2. ## Re: A max function of 2 variables max(a,b)

Originally Posted by Manni
The max function is a function of 2 variables and is defined as follows

max(x,y) = x if x is greater or equal to y or it's = y if x is less than y

How would I go about expressing this piecewise function in one line using an absolute value function?
consider: $\left\{ \frac{|x-y|-(x-y)}{2}+x \right\}$

CB

3. ## Re: A max function of 2 variables max(a,b)

On what basis would I consider that? Maybe I'm missing something, but I don't see its connection with the aforementioned problem.

4. ## Re: A max function of 2 variables max(a,b)

Originally Posted by Manni
On what basis would I consider that? Maybe I'm missing something, but I don't see its connection with the aforementioned problem.
When x>y what is |x-y|-(x-y)?

When x<y what is |x-y|-(x-y)?

CB

5. ## Re: A max function of 2 variables max(a,b)

Oh I understand, can't believe I was oblivious to that. Regardless, thanks a lot. This problem was giving me a headache

6. ## Re: A max function of 2 variables max(a,b)

My apologies, but

when x>y, |x-y|-(x-y) = 0

and when x<y, |x-y|-(x-y) = 2(y-x)

Now the midpoint between them can be expressed as (x+y)/2. And I know that we want to 'go' from the midpoint to the maximum point, so something needs to be added to (x+y)/2 to move from that point. I also know that this expression that we add should be the same regardless of whether x>y or x<y.

This is where I'm stuck. What do I do now?

7. ## Re: A max function of 2 variables max(a,b)

when x>y, |x-y|-(x-y) = 0

and when x<y, |x-y|-(x-y) = 2(y-x)
So, when $x\ge y$, $\frac{|x-y|-(x-y)}{2}+x=x$ and when $x, $\frac{|x-y|-(x-y)}{2}+x=y$, i.e., in both cases $\frac{|x-y|-(x-y)}{2}+x=\max(x,y)$.

Note that $\frac{|x-y|-(x-y)}{2}+x=\frac{x+y+|x-y|}{2}=\frac{x+y+|y-x|}{2}$.

8. ## Re: A max function of 2 variables max(a,b)

Thanks! Finally, I solved it thanks to you guys