<s>[INST] $ \int _ {- 1} ^ {3} [| x ^ 2-6x | + \text{sgn} (x-2)]\, \text {d} x $ 
Calculate the integral $$\int _ {- 1} ^ {3} \bigl[| x ^ 2-6x | + \text{sgn} (x-2)\bigr]\, \text {d} x .$$

We know that the two functions are defined as follows,
\begin{align*}
f (x) &= | x ^ 2-6x |\\[5pt]
&=\begin{cases}
x^2-6x, & \text{ if } x^2-6x>0; \\
6x-x^2, & \text{ if } x^2-6x<0. 
\end{cases}\\[5pt]
&=\begin{cases}
x^2-6x, & \text{ if } x\in(-\infty, 0)\cup (6,+\infty); \\ 
6x-x^2, & \text{ if } x\in(0,6). 
\end{cases}.
\end{align*}
And, $$\text{sgn}(x-2)=\begin{cases}
1, & \text{ if } x>2; \\ 
-1, & \text{ if } x<2. 
\end{cases}$$
I know that the integral gives $ 58 / $ 3. But someone can explain to me the step by step, how to find that result.
I considered doing it with the graph of the function which is the following,

Calculating, the area of ​​the triangle on the left from $ -1 $ to $ 0 $, and then calculating the two on the right and adding it, but I don't know how to calculate the area on the right.
 [/INST] Let's first work on getting a piecewise equation for the whole thing.  There are three points where the pieces can change, namely $x = 0, 2, 6$.  So, we will consider each interval separately when writing down the piecewise equation.  For example, for $x<0$, we need to consider the following:
$$\begin{cases}
\color{red}{x^2-6x}, & \color{red}{x\in(-\infty, 0)\cup (6,+\infty)} \\ 
6x-x^2, & x\in(0,6)
\end{cases} + \begin{cases}
1, & x>2; \\ 
\color{red}{-1}, & \color{red}{x<2}. 
\end{cases} = \boxed{x^2 - 6x - 1,\quad x<0 \ }$$
In the same way we can obtain the rest of the cases:
$$\boxed{| x ^ 2-6x | + \operatorname{sgn} (x-2) = \begin{cases} x^2 - 6x -1, & x<0\\ 6x - x^2 -1, &0<x<2\\ 6x - x^2 + 1, &x>2 \end{cases}}$$
So, this tells us that the integral can be split up as
$$\boxed{\int_{-1}^{0}\bigr[ x^2 - 6x - 1\bigl]\, \text {d}x + \int_{0}^{2}\bigl[6x - x^2 -1\bigr]\, \text {d}x  + \int_{2}^{3}\bigl[6x - x^2 + 1\bigr] \, \text {d}x \ }$$
</s>