# Integrals piecewise / basics

Consider the following function: $$f(x)=\begin{cases} 7-x, &\: 0 \leqslant x \leqslant 7 \\ x-7, &\: 7 \lt x \leqslant 14 \end{cases}.$$ Find the exact value of $\int_0^{14}f(x)\,\mathrm dx$.

I answered 0 because I separated them into two integrals, and I got in both of the integrals 24.5. Therefore, i subtracted them and the answer was 0.

What's the right way to answer this question ?

-
You shouldn't have subtracted them but added them instead. –  Cameron Williams Jul 9 '14 at 1:02
Can you explain why you subtracted? And how do you determine which one subtract which one? –  Gina Jul 9 '14 at 7:09

You're supposed to add the integrals, which would give you a value of 49. To see why, just graph the function and you'll see that the area under the function is always positive (above the x-axis).

-

Compute

$$\int_0^{14} f(x) \, dx=\int_0^7 (7-x)\,dx+\int_7^{14} \, (x-7) \, dx.$$

-

$$\int_0^{14} f(x) \,\mathrm{d}x=\int_0^7 f(x) \,\mathrm{d}x+\int_7^{14} f(x) \,\mathrm{d}x$$

$$=\int_0^7 (7-x)\,\mathrm{d}x+\int_7^{14} (x-7)\,\mathrm{d}x$$

$$=\left[7x-\frac{x^2}{2} \right]_0^7+\left[\frac{x^2}{2}-7x \right]_7^{14}$$

$$=\left[\frac{49}{2}-0 \right]+\left[0--\frac{49}{2} \right]$$

$$\therefore 49$$

-

Hint. The easiest way is to draw the graph of the function and use geometry, not calculus.

-