Class 12 Maths, Worked in Full Past papersGet updates
Chapter 7 · Integrals

Miscellaneous · Q31: ∫14(∣x−1∣+∣x−2∣+∣x−3∣) dx\int_1^4\big(|x-1|+|x-2|+|x-3|\big)\,dx

Miscellaneous ExerciseDefinite integrals of absolute values (P2) · Miscellaneous Exercise
The question

Evaluate the definite integral

∫14[ ∣x−1∣+∣x−2∣+∣x−3∣ ] dx\int_1^4 \big[\,|x-1| + |x-2| + |x-3|\,\big]\,dx
Exam answer

Let I=∫14f(x) dxI = \displaystyle\int_1^4 f(x)\,dx⁠, where f(x)=∣x−1∣f(x) = |x - 1| +∣x−2∣+∣x−3∣+ |x - 2| + |x - 3|⁠.

On [1,2][1, 2]⁠: f(x)=(x−1)+(2−x)f(x) = (x - 1) + (2 - x) +(3−x)=4−x+ (3 - x) = 4 - x⁠.

On [2,3][2, 3]⁠: f(x)=(x−1)+(x−2)f(x) = (x - 1) + (x - 2) +(3−x)=x+ (3 - x) = x⁠.

On [3,4][3, 4]⁠: f(x)=(x−1)+(x−2)f(x) = (x - 1) + (x - 2) +(x−3)=3x−6+ (x - 3) = 3x - 6⁠.

Using ∫abf(x) dx\displaystyle\int_a^b f(x)\,dx =∫acf(x) dx+∫cbf(x) dx= \displaystyle\int_a^c f(x)\,dx + \int_c^b f(x)\,dx (a<c<b)(a < c < b) with c=2c = 2 and c=3c = 3⁠,

I=∫12(4−x) dx+∫23x dx+∫34(3x−6) dx=[4x−x22]12+[x22]23+[3x22−6x]34=(6−72)+(92−2)+(0+92)=52+52+92\begin{aligned} I &= \int_1^2(4 - x)\,dx + \int_2^3 x\,dx \\ &\quad + \int_3^4(3x - 6)\,dx \\ &= \left[4x - \frac{x^2}{2}\right]_1^2 + \left[\frac{x^2}{2}\right]_2^3 \\ &\quad + \left[\frac{3x^2}{2} - 6x\right]_3^4 \\ &= \left(6 - \frac72\right) + \left(\frac92 - 2\right) \\ &\quad + \left(0 + \frac92\right) \\ &= \frac52 + \frac52 + \frac92 \end{aligned}

∴ I=192\therefore\ I = \dfrac{19}{2}⁠.

Want the reason behind every step, the basics and the checks?

The one idea this problem is built on

An absolute value ∣x−c∣|x - c| has one formula to the left of cc and another to the right. The "switch points" here are x=2x = 2 and x=3x = 3 (the point x=1x = 1 is the lower limit). Property P2 lets us cut [1,4][1, 4] at those points, so that on each piece every bar can be removed and the integrand is an ordinary straight line.

Given, to find, and the plan
Given
f(x)=∣x−1∣+∣x−2∣+∣x−3∣f(x) = |x-1| + |x-2| + |x-3| and I=∫14f(x) dxI = \displaystyle\int_1^4 f(x)\,dx⁠.
To find
The exact value of II⁠.
Plan
(1) Continuity. (2) Remove the bars on [1,2][1, 2]⁠, [2,3][2, 3]⁠, [3,4][3, 4]⁠. (3) Split by P2. (4) Integrate each straight-line piece. (5) Add, and cross-check term by term and by the trapezium areas in the graph.

Basics you need

1Absolute value

∣x−c∣=x−c|x - c| = x - c when x≥cx \ge c⁠, and ∣x−c∣=c−x|x - c| = c - x when x≤cx \le c⁠. It is the distance from xx to cc⁠. Basics: symmetry and mirror images

2Property P2 (Section 7.10)

∫abf(x) dx\int_a^b f(x)\,dx =∫acf(x) dx+∫cbf(x) dx= \int_a^c f(x)\,dx + \int_c^b f(x)\,dx for any point cc⁠. Used twice, it splits [1,4][1, 4] at 2 and at 3. Lesson: properties of definite integrals

3The power rule and Theorem 2

∫x dx=x22+C\int x\,dx = \frac{x^2}{2} + C⁠, ∫k dx=kx+C\int k\,dx = kx + C⁠; then ∫abf=F(b)−F(a)\int_a^b f = F(b) - F(a) (Theorem 2, Section 7.8.3). Basics: powers of x and the power rule

4Area as a check

For a function that is never negative, the definite integral is the area under its graph. The area of a trapezium is 12(sum of parallel sides)×width\frac12(\text{sum of parallel sides})\times\text{width}⁠. Basics: area as a sum of thin strips

Solution

  1. The integrand is continuous on [1,4][1, 4]

    Each ∣x−c∣|x - c| is continuous on all of R\R (its two formulas meet at x=cx = c⁠, both giving 0). A sum of continuous functions is continuous, so ff is continuous on [1,4][1, 4]⁠, and Theorem 2 can be used on every piece.

    The absolute values create corners, not jumps. Corners do not matter for integration; only the formula changes there, which is why we split the interval.
    Chapter 5, Section 5.2: ∣x∣|x| is continuous, and sums of continuous functions are continuous. Lesson: definite integrals
  2. Remove the absolute values on each piece

    On [1,4][1, 4] we always have x≥1x \ge 1⁠, so ∣x−1∣=x−1|x - 1| = x - 1 throughout. The other two bars switch at 2 and at 3.

    On [1,2][1, 2]⁠: x≤2≤3x \le 2 \le 3⁠, so

    f(x)=(x−1)+(2−x)+(3−x)=4−x.\begin{aligned} f(x) &= (x-1) + (2-x) + (3-x) \\ &= 4 - x . \end{aligned}

    On [2,3][2, 3]⁠: x≥2x \ge 2⁠, x≤3x \le 3⁠, so

    f(x)=(x−1)+(x−2)+(3−x)=x.f(x) = (x-1) + (x-2) + (3-x) = x .

    On [3,4][3, 4]⁠: x≥3x \ge 3⁠, so

    f(x)=(x−1)+(x−2)+(x−3)=3x−6.\begin{aligned} f(x) &= (x-1) + (x-2) + (x-3) \\ &= 3x - 6 . \end{aligned}

    At the junctions the formulas agree: at x=2x = 2⁠, 4−2=24 - 2 = 2⁠; at x=3x = 3⁠, 3=3⋅3−63 = 3\cdot 3 - 6⁠. So it does not matter which piece the junction is given to.

    Inside each piece, the sign of every bracket x−cx - c is fixed, so each bar is replaced by the bracket itself (if it is ≥0\ge 0⁠) or by its negative (if it is ≤0\le 0⁠). Checking that neighbouring formulas agree at the junctions confirms both the algebra and the continuity of Step 1.
    ∣x−c∣=x−c|x - c| = x - c for x≥cx \ge c⁠; ∣x−c∣=c−x|x - c| = c - x for x≤cx \le c (Basic 1).
  3. Split the integral with P2

    Applying P2 at c=2c = 2 and then at c=3c = 3⁠:

    I=∫12(4−x) dx+∫23x dx+∫34(3x−6) dx.\begin{aligned} I &= \int_1^2 (4 - x)\,dx + \int_2^3 x\,dx \\ &\quad + \int_3^4 (3x - 6)\,dx . \end{aligned}
    P2 holds for any point cc (Section 7.10, proved from Theorem 2). Changing a function's formula at a single point does not change an integral, and here the formulas agree at the junctions anyway, so each piece is exactly the original ff on that interval.
    P2: ∫abf=∫acf+∫cbf\int_a^b f = \int_a^c f + \int_c^b f⁠. Lesson: properties of definite integrals
  4. Integrate each piece

    ∫12(4−x) dx=[4x−x22]12=(8−2)−(4−12)=52.\begin{aligned} \int_1^2 (4 - x)\,dx &= \Big[4x - \tfrac{x^2}{2}\Big]_1^2 \\ &= (8 - 2) - \left(4 - \tfrac12\right) = \tfrac52 . \end{aligned} ∫23x dx=[x22]23=92−2=52.\int_2^3 x\,dx = \Big[\tfrac{x^2}{2}\Big]_2^3 = \tfrac92 - 2 = \tfrac52 . ∫34(3x−6) dx=[3x22−6x]34=(24−24)−(272−18)=92.\begin{aligned} \int_3^4 (3x - 6)\,dx &= \Big[\tfrac{3x^2}{2} - 6x\Big]_3^4 \\ &= (24 - 24) - \left(\tfrac{27}{2} - 18\right) \\ &= \tfrac92 . \end{aligned}

    Check by differentiating the three antiderivatives: ddx(4x−x22)=4−x\frac{d}{dx}(4x - \frac{x^2}{2}) = 4 - x⁠, ddxx22=x\frac{d}{dx}\frac{x^2}{2} = x⁠, ddx(3x22−6x)=3x−6\frac{d}{dx}(\frac{3x^2}{2} - 6x) = 3x - 6 ✓.

    Each piece is a polynomial, so the power rule (standard formula (i), Section 7.2) and Theorem 2 finish it. In the last piece, 272−18=−92\frac{27}{2} - 18 = -\frac92⁠, and subtracting a negative gives +92+\frac92⁠.
  5. Add, and read the answer from the graph

    I=52+52+92=192=9.5.I = \frac52 + \frac52 + \frac92 = \frac{19}{2} = 9.5 .
    x y 1 2 3 4 2 4 6 O (1, 3) (2, 2) (3, 3) (4, 6) 5/2 5/2 9/2
    The graph of y=∣x−1∣+∣x−2∣+∣x−3∣y = |x-1| + |x-2| + |x-3| on [1,4][1, 4] (horizontal and vertical scales differ). It is made of three straight pieces with corners at x=2x = 2 and x=3x = 3⁠. The region under it splits into three trapeziums with areas 52\frac52⁠, 52\frac52 and 92\frac92⁠, total 192\frac{19}{2}⁠.
    Since f≥0f \ge 0⁠, the integral is the area under the graph. The graph passes through (1,3)(1, 3)⁠, (2,2)(2, 2)⁠, (3,3)(3, 3)⁠, (4,6)(4, 6)⁠, so the three trapeziums have areas 3+22=52\frac{3 + 2}{2} = \frac52⁠, 2+32=52\frac{2 + 3}{2} = \frac52 and 3+62=92\frac{3 + 6}{2} = \frac92 (each has width 1). This agrees with Step 4 without any integration.
  6. Cross-check: integrate term by term

    The integral of a sum is the sum of the integrals, so we can also take each bar on its own over [1,4][1, 4]⁠:

    ∫14∣x−1∣ dx=∫14(x−1) dx=[(x−1)22]14=92,\begin{aligned} \int_1^4 |x - 1|\,dx &= \int_1^4 (x - 1)\,dx \\ &= \Big[\tfrac{(x-1)^2}{2}\Big]_1^4 = \tfrac92 , \end{aligned} ∫14∣x−2∣ dx=∫12(2−x) dx+∫24(x−2) dx=12+2=52,\begin{aligned} \int_1^4 |x - 2|\,dx &= \int_1^2 (2 - x)\,dx \\ &\quad + \int_2^4 (x - 2)\,dx \\ &= \tfrac12 + 2 = \tfrac52 , \end{aligned} ∫14∣x−3∣ dx=∫13(3−x) dx+∫34(x−3) dx=2+12=52.\begin{aligned} \int_1^4 |x - 3|\,dx &= \int_1^3 (3 - x)\,dx \\ &\quad + \int_3^4 (x - 3)\,dx \\ &= 2 + \tfrac12 = \tfrac52 . \end{aligned}

    Total: 92+52+52=192\frac92 + \frac52 + \frac52 = \frac{19}{2} ✓, the same.

    Each ∫∣x−c∣\int|x - c| is the area of one or two right triangles: for example ∫14∣x−2∣ dx\int_1^4|x - 2|\,dx is a triangle with legs 1 and 1 (area 12\frac12⁠) plus one with legs 2 and 2 (area 2). The two methods split the same area in different ways.
    Property (III), Section 7.2.1, carried over to definite integrals. Lesson: properties of definite integrals
Result

∫14[ ∣x−1∣+∣x−2∣+∣x−3∣ ] dx=192=9.5\begin{aligned} &\int_1^4 \big[\,|x-1| + |x-2| + |x-3|\,\big]\,dx \\ &= \frac{19}{2} = 9.5 \end{aligned} (Textbook answer: 192\frac{19}{2}⁠.)

Check it with numbers

Numerical integration (adaptive quadrature, with the interval broken at the corners 2 and 3) gives 9.5000000000 ✓.

Spot values: f(1.5)=0.5+0.5+1.5=2.5=4−1.5f(1.5) = 0.5 + 0.5 + 1.5 = 2.5 = 4 - 1.5 ✓; f(2.5)=1.5+0.5+0.5=2.5f(2.5) = 1.5 + 0.5 + 0.5 = 2.5 ✓; f(3.5)f(3.5) =2.5+1.5+0.5= 2.5 + 1.5 + 0.5 =4.5= 4.5 =3(3.5)−6= 3(3.5) - 6 ✓.

Common mistakes
  1. Dropping the bars and integrating (x−1)+(x−2)+(x−3)=3x−6(x-1) + (x-2) + (x-3) = 3x - 6 over all of [1,4][1, 4]⁠. That gives the wrong value ∫14(3x−6) dx=92\int_1^4(3x - 6)\,dx = \frac92⁠, because 3x−63x - 6 is only correct on [3,4][3, 4]⁠.
  2. Splitting only at one point. Every switch point inside the interval (here 2 and 3) needs a cut.
  3. Sign slips in the last piece: F(4)−F(3)=0−(−92)=+92F(4) - F(3) = 0 - (-\frac92) = +\frac92⁠.
What to take away
  1. For ∫∣x−c∣\int|x - c|⁠, find where each bracket changes sign, cut the interval there (P2), and remove the bars piece by piece.
  2. A sum of absolute values of linear terms is a broken line; its integral can always be checked with trapezium areas.

Every fact used, and where it comes from

FactUsed inSource
∣x∣|x| is continuous; sums of continuous functions are continuousStep 1Chapter 5, Section 5.2
Definition of absolute valueSteps 2, 6Earlier classes (Class XI, Chapter 2)
P2: ∫ab=∫ac+∫cb\int_a^b = \int_a^c + \int_c^bSteps 3, 6Section 7.10, property P2
∫xn dx=xn+1n+1+C\int x^n\,dx = \frac{x^{n+1}}{n+1} + C⁠; Theorem 2Step 4Standard formula (i), Section 7.2; Section 7.8.3
Integral of a non-negative function as areaStep 5Section 7.8.1 (area function) (Basics: area)
∫(f+g)=∫f+∫g\int(f + g) = \int f + \int gStep 6Property (III), Section 7.2.1
Found an error, or want more?

Tell us if something on this page is wrong or unclear, or if you would like a fuller explanation, another method or a new feature. Send feedback on this problem →