<s>[INST] Finding solution of the irrational equation Given equation $\sqrt{x + 3 - 2\sqrt{x + 2}} + \sqrt{x + 27 - 10\sqrt{x + 2}} = 4$, find its solution(s).
At first, finding the domain of the function. Noting that $\sqrt{x + 2} \geq 0 \implies x \geq -2$. Then, solving inequalities for $x + 3 - 2\sqrt{x + 2} \geq 0$ and $x + 27 - 10\sqrt{x + 2} \geq 0$ we get that their domain $D = \mathbb{R}$, because quadratics which arise from those inequalities have exactly one root - $S_1 = \{-1\}$ and $S_2 = \{23\}$. Because all expressions are greater than $0$, I am omitting absolute values. 
Solving the equation via substitution $t = \sqrt{x + 2}$ we get:
$$\sqrt{x + 3 - 2t} + \sqrt{x + 27 - 10t} = 4$$
$$x + 3 - 2t = 16 - 8\sqrt{x + 27 - 10t} + x + 27 - 10t$$
$$t^2 - 10t + 25 = x + 27 - 10t$$
$$t^2 = x + 2$$
$$x + 2 = x + 2 \implies S = [-2, \infty).$$
But according to my textbook (which I use as a preparation for entrance exams) the solution must be $S = [-1, 23]$, where -1 and 23 are, obviously not coincidently, solutions to the quadratics, which we obtain while solving expressions under square roots. Where do I have a mistake, then?
 [/INST] Put $t=\sqrt{x+2}$, so we require $t\ge0$. Then $\sqrt{x+3-2t}=\sqrt{t^2+1-2t}=\sqrt{(t-1)^2}=|t-1|$. Similarly, $\sqrt{x+27-10t}=\sqrt{(t-5)^2}=|t-5|$. So we have $|t-1|+|t-5|=4$. That holds for $t\in[1,5]$.
So we must have $1\le\sqrt{x+2}\le5$ and hence $1\le x+2\le25$, so $-1\le x\le 23$.
</s>