8.5. Find all real solutions of the equation $a x^{2}+(a+1)|x|-a-1=0$, where $a$ is a real parameter. ( $|x|$ represents the absolute value of the number $x$ ).
Solution. We note that if the number $x_{0}$ is a solution of the equation

$$
a x^{2}+(a+1)|x|-a-1=0
$$

then the number $-x_{0}$ is also a solution. Therefore, it is sufficient to find only the non-negative solutions of equation (1), and to add their opposites to obtain all solutions.

So, first we will consider equation (1) on the set of values $x \geq 0$. On this set, equation (1) takes the form

$$
a x^{2}+(a+1) x-a-1=0
$$

(since for $x \geq 0$ we have $|x|=x$).

We consider several cases.

1) If $a=0$, equation (2) is a first-degree equation $x-1=0$, which has the solution $x=1$. From the considerations mentioned earlier, the original equation (1) has the solutions: $x_{1}=-1, x_{2}=1$.

In the following, we will consider $a \neq 0$, for which equation (2) is a second-degree equation with the discriminant

$$
D=(a+1)^{2}+4 a(a+1)=(a+1)(5 a+1)=5 a^{2}+6 a+1
$$

which provides several cases.

2) For $a \in\left(-1,-\frac{1}{5}\right)$ the discriminant $D$ is negative and, therefore, equation (2) has no real solutions. Respectively, neither does equation (1).
3) For $a=-1$ equation (2) takes the form $-x^{2}=0$ with the solution $x=0$. In this case, equation (1) also has the solution $x=0$.
4) For $a=-\frac{1}{5}$ equation (2) reduces to the form $-x^{2}+4 x-4=0$, which has the solution $x=2$. In this case, equation (1) has the solutions $x_{1}=-2, x_{2}=2$.
5) For $a \in(-\infty,-1) \cup\left(-\frac{1}{5},+\infty\right)$ equation (2) has two real solutions

$$
\begin{aligned}
& x_{1}=\frac{-a-1-\sqrt{5 a^{2}+6 a+1}}{2 a}=\frac{-a-1}{2 a}-\frac{\sqrt{5 a^{2}+6 a+1}}{2 a} \\
& x_{2}=\frac{-a-1+\sqrt{5 a^{2}+6 a+1}}{2 a}=\frac{-a-1}{2 a}+\frac{\sqrt{5 a^{2}+6 a+1}}{2 a}
\end{aligned}
$$

According to Viète's theorem,

$$
x_{1}+x_{2}=-\frac{a+1}{a}, \quad x_{1} \cdot x_{2}=-\frac{a+1}{a}
$$

We consider the case $-\frac{a+1}{a}0$, i.e., $a \in(-\infty,-1) \cup(0,+\infty)$. In this case, which fits the conditions of p.5), equation (2) has one negative and one positive solution, specifically: for $a \in(-\infty,-1)$ the positive solution is $x=\frac{-a-1-\sqrt{5 a^{2}+6 a+1}}{2 a}$, and in this case, equation (1) has two solutions:

$$
\frac{-a-1-\sqrt{5 a^{2}+6 a+1}}{2 a}, \quad \frac{a+1+\sqrt{5 a^{2}+6 a+1}}{2 a}
$$

and for $a \in(0,+\infty)$ the positive solution is $x=\frac{-a-1+\sqrt{5 a^{2}+6 a+1}}{2 a}$, and in this case, equation (1) also has two solutions:

$$
\frac{-a-1+\sqrt{5 a^{2}+6 a+1}}{2 a}, \quad \frac{a+1-\sqrt{5 a^{2}+6 a+1}}{2 a}
$$

Analogously, the case $-\frac{a+1}{a}>0$ is equivalent to $(a+1) a<0$, i.e., $a \in(-1,0)$, which, under the conditions of p.5), reduces to $a \in\left(-\frac{1}{5}, 0\right)$. In this case, equation (2) has both solutions positive, and equation (1) has four solutions

$$
\frac{-a-1-\sqrt{5 a^{2}+6 a+1}}{2 a}, \quad \frac{a+1+\sqrt{5 a^{2}+6 a+1}}{2 a}
$$

$$
\frac{-a-1+\sqrt{5 a^{2}+6 a+1}}{2 a}, \quad \frac{a+1-\sqrt{5 a^{2}+6 a+1}}{2 a}
$$

Answer:

1) For $a \in(-\infty,-1)$ we have $S=\left\{-\frac{a+1+\sqrt{5 a^{2}+6 a+1}}{2 a}, \frac{a+1+\sqrt{5 a^{2}+6 a+1}}{2 a}\right\}$.
2) For $a=-1$ we have $S=\{0\}$.
3) For $a \in\left(-1,-\frac{1}{5}\right)$ we have $S=\emptyset$.
4) For $a=-\frac{1}{5}$ we have $S=\{-2,2\}$.
5) For $a \in\left(-\frac{1}{5}, 0\right)$ we have $S=\left\{-\frac{a+1+\sqrt{5 a^{2}+6 a+1}}{2 a}, \frac{a+1+\sqrt{5 a^{2}+6 a+1}}{2 a},-\frac{a+1-\sqrt{5 a^{2}+6 a+1}}{2 a}, \frac{a+1-\sqrt{5 a^{2}+6 a+1}}{2 a}\right\}$.
6) For $a=0$ we have $S=\{-1,1\}$.
7) For $a \in(0,+\infty)$ we have $S=\left\{-\frac{a+1-\sqrt{5 a^{2}+6 a+1}}{2 a}, \frac{a+1-\sqrt{5 a^{2}+6 a+1}}{2 a}\right\}$.