y=xxy = x|x|

Graph of the Function y=xxy = x|x|

y=xxy = x|x| equals x2x^2 for x0x \geq 0 and x2-x^2 for x<0x < 0. It keeps the right half of a parabola and reflects the left half through the origin, turning the even function x2x^2 into an odd one. It is the simplest well-known example of a function that can be differentiated once but not twice.

Domain and symmetry

Both the domain and the range are all of the real numbers. Since f(x)=(x)x=xx=f(x)f(-x) = (-x)|-x| = -x|x| = -f(x), the function is odd, with rotational symmetry about the origin. It is positive for x>0x > 0 and negative for x<0x < 0, and the origin is its only zero.

Range of xxyyyy'yy''
x<0x < 0x2-x^22x-2x2-2
x=0x = 00000undefined
x>0x > 0x2x^22x2x22

Monotonicity

The derivative is 2x2x for x>0x > 0 and 2x-2x for x<0x < 0, which can be written together as a single formula.

y=2xy' = 2|x|

At the origin the one-sided derivatives are both 00 and therefore agree, so y(0)=0y'(0) = 0 is well defined. The derivative thus exists on the whole real line and is continuous. Since y0y' \geq 0 the function increases throughout and has no extrema.

Differentiable once but not twice

The derivative y=2xy' = 2|x| is continuous, but being an absolute value it is not differentiable at the origin. The second derivative is 22 for x>0x > 0 and 2-2 for x<0x < 0, values that disagree at 00. The function is therefore continuously differentiable once but not twice. In a single short formula it shows that smoothness comes in degrees.

Concavity

From the sign of the second derivative, the curve is concave up for x>0x > 0 and concave down for x<0x < 0, so the concavity reverses at the origin, making it an inflection point. The tangent there is horizontal and yet there is no extremum, just as for y=x3y = x^3.

FunctionSlope at the originThe originHow often differentiable
y=x3y = x^300inflection pointany number of times
y=xxy = x|x|00inflection pointonce only

The difference is that x3x^3 can be differentiated any number of times, whereas this function stumbles on the second derivative. The two graphs meet at x=0x = 0 and x=±1x = \pm 1, with xxx|x| bulging further out near the origin.

Inverse function

On the side where y0y \geq 0, solving y=x2y = x^2 gives x=yx = \sqrt{y}; where y<0y < 0, solving y=x2y = -x^2 gives x=yx = -\sqrt{-y}. Together the inverse is written as follows.

y=sign(x)xy = \operatorname{sign}(x)\sqrt{|x|}

This is the so-called signed square root, the even function x\sqrt{|x|} rebuilt as an odd one. It is constructed in exactly the same way as the original function.

Integral

The antiderivative is x2x3\dfrac{x^2|x|}{3}, which equals x33\dfrac{x^3}{3} for x>0x > 0 and x33-\dfrac{x^3}{3} for x<0x < 0; differentiating on either interval returns xxx|x|. Being odd, the function integrates to 00 over any interval symmetric about the origin.

Applications

Air resistance proportional to the square of the speed is written, once direction is taken into account, as proportional to vv-v|v|. Writing simply v2-v^2 would leave the drag pointing backwards even when the body moves backwards; multiplying by v|v| keeps the magnitude quadratic while making the direction always oppose the motion. A plot of drag against velocity is exactly this curve. In numerical analysis it also serves as a test function for checking the order of smoothness a method requires.