1

Is there an $f$ that takes two values $a$ and $b$ and if $b>a$, it returns $f(a,b) = b-a$ otherwise $f(a,b) = 0$?

Is the $f$ linear?

P.S: I think one can find the maximum between $a$ and $b$ and then subtract $a$ from the maximum to get the desired $f$ described above.

Mahdi
  • 305

1 Answers1

0

The following is "almost" linear $$ \max\{a,b\}=\frac{a+b+|a-b|}{2} $$

boaz
  • 4,783
  • based on your comment I think $f$ could be $f(a,b) = \frac{a+b+|a-b|}{2} -a$. But why "almost" linear? – Mahdi Oct 17 '16 at 17:10
  • Why you need the $-a$? in the title you asked for the maximum. A linear function is one of the form $f(x_1,\ldots,x_n)=a_1 x_1+\ldots+a_nx_n$, not including absolute values. – boaz Oct 17 '16 at 17:14
  • You are right. What I really need is in the body of the question but actually did not know how to call an $f$ with such property. So I thought I can get the max and then use $-a$! How should such an $f$ be called? – Mahdi Oct 17 '16 at 17:17