$ \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.
 A: You have all the necessary details in your explanation. It's just a matter of cleverly splitting the integral.
$$\int_{-1}^3 [|x^2-6x| + \operatorname{sgn}(x-2)]dx = \int_{-1}^0 [x^2 - 6x -1] dx + \int_0^2 [6x - x^2 -1]dx + \int_2^3[6x - x^2 +1] dx$$
Now you can integrate the three integrals separately
General strategy Say you are trying to integrate a piecewise function on $[a,b]$
$$f = \begin{cases} f_1 & x \in (x_1, x_2) \\
f_2 & x \in (x_2, x_3) \\ 
\vdots \\
f_n & x \in (x_n, x_{n+1})\end{cases}$$
It helps to split the integral in the following fashion
$$\int_a^b f = \int_{x_1}^{x_2} f_1 + \dots + \int_{x_n}^{x_{n+1}}f_n$$
In your case, the function you are trying to integrate was over $[-1,3]$ and the pieces, like you figured out were
$$f = |x^2 - 6x|+\operatorname{sgn}(x-2) = \begin{cases} x^2-6-1 & x \in (-1,0) \\ 6x-x^2-1 & x\in (0,2) \\ 6x-x^2 +1 & x\in (2,3) \end{cases}$$
A: 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 \ }$$
A: Basic strategy in these type of problems involving Piece-wise functions is that Firstly you have to look at Limits of your integral and then check if Point of discontinuity(Here $0$ ,$2$ and $6$) lies in limit of your integral. If They lies You have to use Linearity of integral.
$$I=\int _ {- 1} ^ {3} \bigl[| x ^ 2-6x | + \text{sgn} (x-2)\bigr]\, \text {d} x $$
You have already determine Points where we have to use linearity of integral.
$$I=\int _ {- 1} ^ {0} (x ^ 2-6x  -1 )dx + \int _ {0} ^ {2} (-x ^ 2+6x  -1) dx +\int _ {2} ^ {3} (-x ^ 2+6x  +1) dx$$
Now, You can evaluate integrals easily.
