14

Is there a mathematical symbol that truncates a value x to 0 if it is negative, and leaves it untouched otherwise? Something which is logically equivalent to $\max(x, 0)$?

lindelof
  • 275
  • 1
  • 2
  • 7

3 Answers3

17

I have seen the notation $z^+$ to denote $\max\{z,0\}$ in many papers and books. Analogously, $z^-$ to denote $-\min\{z,0\}$. Wikipedia uses that notation too.


EDIT (thanks to @rzippo) : Note that $z^-$ denotes the so-called negative part, which is non-negative. If we want a function that simply truncates positive values to zero, then we would need the function $f(z)=\min\{z,0\}$ (without the minus sign), for which I do not know any particular notation.

AugSB
  • 5,007
  • 3
    This is freaking awesome and it gives me goosebumps. I am solving a programming issue. And I had the same question. This shows that know your math can help you where you expect it the least. Instead of writing 3 lines of code, I will just call the max() function which takes an unlimited number of arguments and 0 will be one of them. I love Math. Thanks for this answer. – asiby Jun 27 '19 at 16:06
  • @asiby Thanks! I think that was the most grateful comment anyone wrote to me in SE. – AugSB Jun 27 '19 at 16:23
  • Thanks to you. You are very welcome. I was speaking from the heart. Keep up contributing. ;) – asiby Jun 27 '19 at 16:44
  • One thing I was finding confusing is the minus sign in $z^- = -\min{z,0}$. What you are describing is the negative part function, which is meant to be non-negative. It does not simply truncate positive values, as one would expect given the context of this answer. – rzippo Dec 10 '19 at 16:52
  • @rzippo I think we are both right. If we talk about truncating positive values, the minus sign should not appear. But it is also true, that when talking about the operator $z^+$ (the real aim of the question), it is also worth talking about its pair $z^-$, isn't it? Anyway, thanks for the clarification. I will add it to the answer. – AugSB Dec 11 '19 at 07:16
16

How about adding the absolute value of the number to the number, and then dividing by 2. If the number is negative, the total will be zero, which divided by 2 is still zero. If the number is positive or zero, the result will be the number you began with.

  • 5
    This is a good answer, but not to quite the right question - this one asks for a symbol. Upvoted as I came here looking for a method rather than a symbol! – Ari Cooper-Davis Jan 11 '19 at 14:56
  • 3
    As a matter of fact, this would be a particular case of using $\max(x,y)=\frac{1}{2}(x+y+|x-y|)$ for $y=0$, which relates to my answer above. – AugSB Jun 27 '19 at 16:22
0

$\frac12(x+\sqrt{x^2})$ will zero all negative values of $f(x)$.

$\frac12(x-\sqrt{x^2})$ will zero all positive values of $f(x)$.

user1729
  • 31,015