# Is there a name for the function $\max(x, 0)$?

Is there a name for the function $\max(x, 0)$?

For comparison, the function $\max(x, -x)$ is known as the absolute value (or modulus) of x, and has its own notation $|x|$

• should there be a name for this function? is it important enough to get its own name? is it used often enough to warrant an abbreviation? does it capture something so profound to be worth naming? If you answer any of these question positively, then you can improve your question. Aug 15 '14 at 10:20
• In finance max(x-s,0) is the payoff of a call option where s is the strike price and x is the price of the underlying stock on the expiry date. Aug 15 '14 at 11:06
• The question asks for the name of the operation, not an example of something that is computed using it. The operation $\max(x,0)$ isn't called "payoff of a call option", just as the operation of multiplication isn't called "force", despite Newton's second law. Aug 16 '14 at 20:37
• @ColonelPanic - a notation that is frequently used for the payoff of a call option is $(x-s)_{+}$, especially in actuarial science. Aug 17 '14 at 1:58

This is called the positive part of the real number $x$, and often denoted by $x^+$.

Likewise, the negative part of $x$ is $x^-=\max\{-x,0\}$ and the pair of nonnegative real numbers $(x^+,x^-)$ is fully characterized by the pair of identities $$x=x^+-x^-,\qquad\lvert x\rvert=x^++x^-.$$

• It should be noted that the negative part is, in fact, a positive number. For example the negative part of -3 is 3. Aug 15 '14 at 13:19
• Indeed the positive part and the negative part are both nonnegative numbers.
– Did
Aug 15 '14 at 15:51
• Similarly, the imaginary part of a complex number is a real number. Aug 15 '14 at 22:40
• I would rather call this the "positive part of the identity function", because the "positive part" definition as you cite it refers to functions and not numbers. Aug 16 '14 at 13:34
• @example Thanks for your input. It just happens that this (i.e., the positive part of the real number $x$) is what mathematicians call it (i.e., $\max(x,0)$).
– Did
Aug 16 '14 at 13:42

Wikipedia calls this the ramp function and notes that it can be written using Macaulay brackets.

$\{x\} = \begin{cases} 0, & x < 0 \\ x, & x \ge 0. \end{cases}$

Since this is a math site, not a programming site, my answer may or may not be regarded as trivia. Anyway...

In computer graphics this function is called clamping. The general form is $\mathrm{clamp(x, lowerBound, upperBound)}$ and is defined as

function clamp(x, lowerBound, upperBound):
if(x < lowerBound)
return lowerBound
else if(x > upperBound)
return upperBound
else
return x


or $\mathrm{min( max(x, lowerBound), upperBound)}$.

$\max(x,0)$ is the special case $\mathrm{clamp}(x, 0, +\infty)$.

The clamping function is ubiquitous in computer graphics: You often need to confine a calculated value (e.g. a color intensity) into a range of valid values (e.g. $[0,1]$ or $[0,255]$).

• It looks like Java, only function is not Java. Replacing function with something like public static int makes it Java, a method to be inserted in some class. Aug 16 '14 at 9:40
• It's pseudocode. Aug 16 '14 at 10:14
• It's pseudocode and can trivially easily be translated into Python, JS or anything else. @OutlawLemur It's not literal Python because of a few minor differences: a) function clamp(...) instead of def clamp(...): b) No colons at the end of the if/elif/else lines c) Conditional expressions enclosed by parentheses if(x < lowerBound) instead of if x < lowerBound:
– smci
Aug 17 '14 at 0:31
• @MickG Even if you replaced function with public static int, it would still be a long way away from being Java. Aug 17 '14 at 11:53
• @MickG: It is much closer to Python than Java.
– Reid
Aug 17 '14 at 19:55

You can check that:

$$\color{blue}{\max(x,0) = x \, H(x)}$$

where $H(x)$ is the Heaviside or unit step function. A name for this? Not a clue, but hope it helps.

• This is actually a pretty nice implementation. For example, here's a quick and dirty computation of the derivative for $x \neq 0$: $$\frac{d}{dx} \max(x,0) = \frac{d}{dx} H(x)\cdot x = H(x) \frac{d}{dx} x = H(x) \cdot 1 = H(x).$$ It works because $H(x)$ is basically a constant. More precisely, the function $$\begin{cases} 1 & x>0 \\ 0 & x < 0\end{cases}$$ is a locally constant openly-supported partial functions $\mathbb{R} \rightarrow \mathbb{R}$, which is exactly what you need in order to treat it as a constant insofar as differentiation is concerned. Aug 5 '17 at 4:12

I have heard this function called the rectifier. This is a pretty exclusive field name though, and I wouldn't expect to see it anywhere outside of neural networks.

• I think the use in neural networks derives from the use of the term in electrical engineering: en.wikipedia.org/wiki/Rectifier Aug 16 '14 at 2:27
• @A.Donda Thanks for the information.
– Did
Aug 16 '14 at 13:05
• This might be a newer coinage than when this answer was originally written, but as of 2021 the term "ReLU" (for rectified linear unit) is also frequently used for this function.
– Emil
Sep 17 at 12:03

You can use:

$$f(x) = \frac{x + |x|}{2}$$

• I suppose that's interesting, but it's not at all what the question is asking.
– Ray
Aug 15 '14 at 18:38
• The point is that the function doesn't need a name, it can be expressed in terms of $|x|$ and $x$. Aug 15 '14 at 18:42
• So squaring doesn't need a name because it can be expressed in terms of $x$ and $2$? And factorial doesn't need a name because it can be expressed in terms of product? And... Aug 16 '14 at 20:40
• @DavidRicherby It's not about that. We call $x^2$ squaring but we don't have a name for $x^2+3$. We have a name for $n!$ but not one for $(-1)^nn!$. So perhaps a name for the function described is not really needed. It turns out it does have a name, but if it didn't and you needed to use it in a paper, for instance you can just give it a special letter and define it at the beggining of the paper and it would be ok. Aug 17 '14 at 8:19
• How is (x+|x|)/2 better then max(x, 0) anyway? Aug 17 '14 at 9:26