2. Determine all values of the real parameter $a$ for which the equation

$$
\sqrt{a x^{2}+a x+2}=a x+2
$$

has a solution.
Solution. If $a x+2<0$, then the equation has no solution, and if $a x+2 \geq 0$, then it is equivalent to the equation $\left(a^{2}-a\right) x^{2}+3 a x+2=0$.

The following cases are possible:

i) The coefficient of $x^{2}$ is equal to 0 and the corresponding linear equation has a root for which $a x+2 \geq 0$. For $a=0$ we get $2=0$, which is not possible. For $a=1$ we get $x=-\frac{2}{3}$ and since $a x+2=-\frac{2}{3}+2 \geq 0$, we conclude that $a=1$ is a solution to the problem.

ii) The coefficient of $x^{2}$ is not zero, $(a \neq 0,1)$ and the corresponding quadratic equation has a unique solution that satisfies the condition $a x+2 \geq 0$. Then, for the equation to have a unique solution, we need

$$
D=9 a^{2}-8\left(a^{2}-a\right)=a^{2}+8 a=0
$$

We get $a=0$ or $a=-8$. But, $a \neq 0$, so we are left with $a=-8$, in which case we get $x=\frac{1}{6}$ and $a x+2=-8 \cdot \frac{1}{6}+2 \geq 0$, which means that $a=-8$ is a solution to the problem.

iii) The coefficient of $x^{2}$ is not zero ( $a \neq 0,1$ ), and the corresponding quadratic equation has two roots $x_{1}$ and $x_{2}$ such that $a x_{1}+2<0$ and $a x_{2}+2 \geq 0$. The latter means that the number $-\frac{2}{a}$ lies between the roots of the equation, and it may coincide with the larger root. If $-\frac{2}{a}=x_{2}$, we get

$$
\left(a^{2}-a\right)\left(-\frac{2}{a}\right)^{2}+3 a\left(-\frac{2}{a}\right)+2=0
$$

from which we get $a=0$, which is a contradiction. Therefore, $-\frac{2}{a}$ does not coincide with either of the roots. From this, it follows that the inequality

$$
\left(a^{2}-a\right)\left(\left(a^{2}-a\right)\left(-\frac{2}{a}\right)^{2}+3 a\left(-\frac{2}{a}\right)+2\right)<0
$$

is satisfied, which guarantees the existence of two roots. Simplifying the last inequality, we get $a \geq 1$.

Finally, the solution to the problem is $a=-8$ and $a \geq 1$.