returns when is positive and when it is negative1. Called the ramp function or the positive part, it consists of two half-lines meeting at a corner at the origin. The formula is plain, but as an example sitting on the boundary of differentiability, and as an activation function in machine learning, its reach is wide.
The larger of two numbers can be written . Taking and gives the following.
The relation also runs the other way.
The absolute value and the ramp function build each other, through a sum and a difference.
The domain is all real numbers and the range is . The graph lies along the -axis on the negative side and along the line on the positive side.
| Range | ||
|---|---|---|
| undefined | ||
The derivative from the right is and from the left is , and they disagree, so the function is not differentiable at the origin. It is continuous, so like the absolute value it is an example of a function that is continuous without being differentiable.
Away from the origin the derivative is the Heaviside step function2. Conversely, integrating the step function gives the ramp function.
The function is convex. A segment joining two points on the graph always lies above it, and the single bend turns downward. Allowing translations and scalar multiples, sums of ramp functions produce any convex polyline whatever. That every piecewise linear convex function is a linear combination of ramp functions is the ground on which the applications rest.
The antiderivative is as follows.
It equals for and for . That function is continuous and differentiable once, but its second derivative disagrees at the origin.
| Function | Smoothness at the origin |
|---|---|
| The Heaviside step function | discontinuous |
| The ramp function | continuous but not differentiable |
| Its antiderivative | differentiable once |
Each integration raises the smoothness by one step, as this shows.
In machine learning this function goes by the name ReLU and is used as an activation function, widely adopted because the gradient does not easily vanish even through many layers. That the whole network becomes a piecewise linear function follows from the convexity and the superposition just described.