Artificial intelligent assistant

Fundamental theorem of calculus with a piece wise function The problem is: Let $$f(x) = \left\\{ \begin{array}{ccc} 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{array} \right.$$ and let $$g(x) =\int^x_0 f(t)\ dt $$ Find a formula for $g(x)$ that doesn't involve integrals. How would I procede to integrate $f(x)$ with each value? The problem that confuses me is that there are two variables. There is a $g(x)$ variable, $x$, that effects the upper bound of the integral. Then there is the $x$ in $f(x)$, which would be $t$, but how would I integrate the piece wise the function in this condition with $g(x) $.

For $x\leq 0$, $g(x)=\int_0^x 0dt =0$.

For $0\leq x \leq 1$ , $g(x)=\int_0^x tdt=x^2/2$.

For $1\leq x\leq2$, $g(x)=\int_0^1 tdt +\int_1^x (2-t)dt=2x -x^2/2 -1$.

For $x\geq 2$, $g(x)=\int_0^1 tdt +\int_1^2 (2-t)dt + \int_2^x 0dt=1$.

The idea is to break the integral up as a sum of integrals on intervals where each piece of the piecewise-defined integrand lives, using the fact that $\int_a^c=\int_a^b +\int_b^c$.

And since the upper limit is variable, how you break it up will depend on what the upper limit is; I've considered all the possibilities above. Putting them all together,

$$ 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} $$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 7f047b765c89add9bdd287b5db160741