Finding roots of a specific Function How can I calculate the roots of this equation? What about in MATLAB?
x2=N(N(x2))
The plot of the function is in below:

 A: If I understand correctly, $N$ is the function defined piecewise by
$$
N(x) = \begin{cases}
5 & x \leq 2, \\
9 - 2x & 2 < x < 4, \\
1 & x \geq 4.
\end{cases}
$$
We can then calculate what $N(N(x))$ is.


*

*If $x \leq 2$ then $N(x) = 5$, so $N(N(x)) = N(5) = 1$.

*If $x \geq 4$ then $N(x) = 1$, so $N(N(x)) = N(1) = 5$.

*If $2 < x < 4$ then $N(x) = 9-2x$. Since we're plugging this back into $N$, we want to know when $2 < 9-2x < 4$. Subtracting $9$ from this gives $-7 < -2x < -5$, and dividing by $-2$ gives $5/2 < x < 7/2$.
In the range $5/2 < x < 7/2$ we thus have
$$
 N(9-2x) = 9 - 2(9-2x) = 4x - 9.
 $$
In the range $x \leq 5/2$ we have $9-2x \geq 4$, so that here $N(9-2x) = 1$.
In the range $x \geq 7/2$ we have $9-2x \leq 2$, so that here $N(9-2x) = 5$.
In summary,
$$
 N(9-2x) = \begin{cases}
 1 & x \leq 5/2, \\
 4x - 9 & 5/2 < x < 7/2, \\
 5 & x \geq 7/2.
 \end{cases}
 $$
Combining these three bullet points, we conclude that
$$
N(N(x)) = \begin{cases}
1 & x \leq 5/2, \\
4x - 9 & 5/2 < x < 7/2, \\
5 & x \geq 7/2.
\end{cases}
$$

Now, you are interested in determining which values of $x$ satisfy
$$
x = N(N(x)). \tag{1}
$$
Since $N(N(x)) = 1$ for $x \leq 5/2$, the only solution to equation $(1)$ with $x \leq 5/2$ is $x = 1$.
If $5/2 < x < 7/2$ then $N(N(x)) = 4x - 9$, and if we set
$$
x = 4x-9
$$
then we get $x = 3$. This falls in the range $5/2 < x < 7/2$, so this is a true solution to equation $(1)$.
If $x \geq 7/2$ then $N(N(x)) = 5$, so the only solution to equation $(1)$ in this interval is $x=5$.
In total, the solutions to equation $(1)$ are $x=1$, $x=3$, and $x=5$.
Here is a plot of $N(N(x))$ in blue versus $x$ in orange.

This was created in Mathematica using the code
n[x_] := Piecewise[{{5, x < 2}, {9 - 2 x, 2 < x < 4}, {1, x > 4}}];
Plot[{n[n[x]], x}, {x, 0, 6}, PlotPoints -> 70]

