Graphing absolute values: piecewise formulas, reflections, and root counts

Original publication: Updated:

Two basic ways to handle an absolute value

For any real uu,

∣u∣={−u,u<0,u,u≥0.|u|=\begin{cases}-u,&u<0,\\u,&u\ge0.\end{cases}

A graph involving absolute values can therefore be drawn by splitting the domain where the expressions inside change sign. A useful special case is y=∣f(x)∣y=|f(x)|: retain the parts of y=f(x)y=f(x) above the horizontal axis and reflect every part below it across that axis.

The reflection rule applies to an absolute value around the whole output. It cannot be applied indiscriminately to every expression that happens to contain absolute values.

Example: two linear absolute values

For y=∣x−1∣+∣x−3∣y=|x-1|+|x-3|, the sign-change points are 11 and 33. Thus

y={4−2x,x<1,2,1≤x<3,2x−4,x≥3.y=\begin{cases}4-2x,&x<1,\\2,&1\le x<3,\\2x-4,&x\ge3.\end{cases}

The pieces meet continuously at (1,2)(1,2) and (3,2)(3,2).

The graph of |x-1|+|x-3|: a descending line, a horizontal segment at height 2 from x=1 to x=3, and an ascending line.

Example: reflect a cubic

First draw y=x3−3xy=x^3-3x. Its derivative is 3(x−1)(x+1)3(x-1)(x+1), so it has a local maximum 22 at x=−1x=-1 and local minimum −2-2 at x=1x=1.

The factorization x3−3x=x(x−3)(x+3)x^3-3x=x(x-\sqrt3)(x+\sqrt3) gives three zeros: −3,0,3-\sqrt3,0,\sqrt3.

The cubic y=x cubed-3x, with its local maximum and minimum and its three horizontal-axis crossings.

Reflect the portions with negative output to obtain y=∣x3−3x∣y=|x^3-3x|:

The absolute-value cubic, with the negative portions of the original reflected upward and shown against the original dashed curve.

The three zeros stay in the same positions. Reflection changes heights, not horizontal coordinates.

Problem 1: an area bounded by a V-shaped graph

Problem. Find the area enclosed by y=∣2x+2∣+2y=|2x+2|+2 and y=6y=6.

Split at x=−1x=-1:

y={−2x,x<−1,2x+4,x≥−1.y=\begin{cases}-2x,&x<-1,\\2x+4,&x\ge-1.\end{cases}

The vertex is (−1,2)(-1,2).

The V-shaped graph y=|2x+2|+2 with its vertex at (-1,2).

The line y=6y=6 intersects the two branches at x=−3x=-3 and x=1x=1. The enclosed triangle has base length four and height four, so its area is

12⋅4⋅4=8.\boxed{\frac12\cdot4\cdot4=8.}

The triangle bounded by the absolute-value graph and the horizontal line y=6, shaded between x=-3 and x=1.

The source presents this as a past numerical-reasoning problem from a Japanese civil-service examination. Its key step is recognizing the elementary triangle rather than introducing an unnecessary integral.

Problem 2: the least uniform bound on an interval

Problem. For a given real number aa, find the least real kk such that

∣x2+x+a∣≤k|x^2+x+a|\le k

for every xx with −1≤x≤1-1\le x\le1.

This asks for the maximum of the absolute value on the interval. Complete the square:

x2+x+a=(x+12)2+a−14.x^2+x+a=\left(x+\frac12\right)^2+a-\frac14.

The vertex lies inside the interval, giving minimum value a−1/4a-1/4. The maximum of the unreflected quadratic occurs at x=1x=1 and is a+2a+2. Hence its output range is exactly [a−1/4,a+2][a-1/4,a+2], and

kmin⁡=max⁡(∣a−14∣,∣a+2∣).k_{\min}=\max\left(\left|a-\frac14\right|,|a+2|\right).

The two extremes have equal absolute value when a−1/4=−(a+2)a-1/4=-(a+2), or a=−7/8a=-7/8. Consequently

kmin⁡(a)={14−a,a≤−78,a+2,a≥−78.\boxed{k_{\min}(a)=\begin{cases}\frac14-a,&a\le-\frac78,\\a+2,&a\ge-\frac78.\end{cases}}

At the shared boundary both formulas equal 9/89/8.

An upward quadratic on [-1,1], with vertex height a-1/4 and right-endpoint height a+2.

The graph after reflecting its negative part, showing the reflected vertex height 1/4-a competing with the right-endpoint height.

The range calculation handles all aa, including values for which the entire original graph lies below the axis. If one additionally minimizes over aa, the best choice is a=−7/8a=-7/8 and the least possible bound is 9/89/8; that is a separate optimization from finding kmin⁡k_{\min} for a fixed aa.

Problem 3: count distinct real roots

Problem. For each real aa, determine the number of distinct real solutions of

x∣x−3∣=ax+1.x|x-3|=ax+1.

Write the fixed graph as

y=x∣x−3∣={−x2+3x,x<3,x2−3x,x≥3.y=x|x-3|=\begin{cases}-x^2+3x,&x<3,\\x^2-3x,&x\ge3.\end{cases}

We count its intersections with the line y=ax+1y=ax+1.

The piecewise quadratic y=x|x-3| and several lines through (0,1), including tangencies and a line through (3,0).

The branch x < 3

Its intersections satisfy

x2+(a−3)x+1=0.x^2+(a-3)x+1=0.

Tangency occurs when (a−3)2−4=0(a-3)^2-4=0, giving a=1a=1 or a=5a=5. The double roots are x=1x=1 and x=−1x=-1, respectively, so both are in the correct branch.

An intersection can also pass through the branch boundary (3,0)(3,0). This occurs when 3a+1=03a+1=0, or a=−1/3a=-1/3.

For a<−1/3a<-1/3, the left quadratic has one root below three and one above three, so only one counts. At a=−1/3a=-1/3, its roots are 1/31/3 and 33; the latter is excluded from this branch. For −1/3<a<1-1/3<a<1, both roots are below three. For 1<a<51<a<5, the discriminant is negative. For a>5a>5, both roots are negative and therefore below three. At a=1,5a=1,5, the double root contributes one distinct intersection.

The branch x >= 3

Here the equation is

x2−(a+3)x−1=0.x^2-(a+3)x-1=0.

Its two roots have opposite signs. The positive one lies at or above three precisely when the polynomial's value at three is nonpositive:

−3a−1≤0⟺a≥−13.-3a-1\le0\quad\Longleftrightarrow\quad a\ge-\frac13.

Thus this branch contributes one root when a≥−1/3a\ge-1/3 and none otherwise. The boundary root x=3x=3 is counted here only, preventing duplication.

Combine the counts

The total number of distinct real roots is:

  • a<−1/3a<-1/3: one.
  • a=−1/3a=-1/3: two.
  • −1/3<a<1-1/3<a<1: three.
  • a=1a=1: two.
  • 1<a<51<a<5: one.
  • a=5a=5: two.
  • a>5a>5: three.

A discriminant calculation alone would overcount roots that lie outside a branch's domain. Check both the tangent point and every ordinary root against the interval where the chosen piecewise formula is valid.

Related: root placement in intervals and graphical parameter separation.

Related articles

About the author

Koki Saito

Physician and graduate of the University of Tokyo Faculty of Medicine. Drawing on his entrance-exam experience, he explains how to choose mathematical methods and construct complete solutions.

Full profile →

Have a question or spotted an error? Contact us.