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?

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

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.

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

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

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?

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}$.

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

Thanks! Finally, I solved it thanks to you guys :)