# Integrating Piecewise function

If someone could please help me with this question I would be so grateful!

Let $$f(x) = \begin{cases} 0 & & x < 0 \Large\strut \\ x & & 0 \leq x \leq 1 \Large\strut \\ 2-x & & 1 \leq x \leq 2 \Large\strut \\ 0 & & x>2 \Large\strut \end{cases}$$

and

$$g(x) = \int_{0}^{x} f(t) dt$$

Find the formula for $g(x)$ similar to $f(x)$.

I already know the answer to this question (listed below), however, I don't understand how to integrate properly to get these answer to $g(x)$. I would appreciate it if someone could just walk me through each answer and explain how they got it. Thank you in advance!

$$g(x)= \begin{cases} 0 & x\leq 0 \\ x^2/2 & 0\leq x\leq 1 \\ 2x-x^2/2 - 1& 1\leq x\leq 2 \\ 1 & x \geq 2 \end{cases}$$

-

## 1 Answer

Hint. If $1\le x\le2$ then $$g(x)=\int_0^x f(t)\,dt=\int_0^1 f(t)\,dt+\int_1^x f(t)\,dt\ .$$ Now substitute the formulae for $f(t)$ into the right hand side. Note that the two integrals will involve different expressions for $f(t)$. Then you should have no trouble doing the integrals.

Finally, do something similar for other values of $x$.

-