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

• Sep 24th 2011, 04:23 PM
Manni
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?
• Sep 25th 2011, 01:31 AM
CaptainBlack
Re: A max function of 2 variables max(a,b)
Quote:

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:$\displaystyle \left\{ \frac{|x-y|-(x-y)}{2}+x \right\}$

CB
• Sep 25th 2011, 09:56 AM
Manni
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.
• Sep 25th 2011, 07:14 PM
CaptainBlack
Re: A max function of 2 variables max(a,b)
Quote:

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
• Sep 25th 2011, 07:32 PM
Manni
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
• Sep 27th 2011, 04:30 PM
Manni
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?
• Sep 27th 2011, 04:47 PM
emakarov
Re: A max function of 2 variables max(a,b)
Quote:

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

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

Note that $\displaystyle \frac{|x-y|-(x-y)}{2}+x=\frac{x+y+|x-y|}{2}=\frac{x+y+|y-x|}{2}$.
• Sep 27th 2011, 05:05 PM
Manni
Re: A max function of 2 variables max(a,b)
Thanks! Finally, I solved it thanks to you guys :)