<s>[INST] Solving $\sqrt{(\log_2x)^2 - 5|\log_2x| + 6} \le 2\sqrt{5}$ My attempt:
Given,
$$\sqrt{(\log_2x)^2 - 5|\log_2x| + 6} \le 2\sqrt{5}$$
Taking $t=|\log_2x|$:
$$\sqrt{t^2-5t+6} \le 2\sqrt{5}$$
I know that squaring both sides will lead to extraneous solutions. In fact, I solved the rest of the problem by squaring sides and got $x \in \left[\dfrac{1}{128},128\right]$ whereas the correct answer according to Wolfram Alpha is $x \in \left[\dfrac{1}{128},\dfrac{1}{8}\right] \cup \left[\dfrac{1}{4}, 4\right] \cup [8,128]$.
What is the correct way of solving this problem that avoids extraneous solutions?
 [/INST] This inequality is quite fiddly, but with care we can get to the solution. First, note that any inequality of the form $\sqrt{a}\le b$ is equivalent to $a\le b^2$ and $a\ge0$, meaning
\begin{align}
\sqrt{t^2-5t+6}\le2\sqrt{5} &\iff t^2-5t+6\le20 \quad\text{and}\quad t^2-5t+6\ge0 \\[5pt]
&\iff (t+2)(t-7)\le0\quad\text{and}\quad(t-2)(t-3)\ge0 \\[5pt]
&\iff t\in[-2,7]\quad\text{and}\quad t\not\in(2,3) \\[5pt]
&\iff t\in\left([-2,7]\setminus(2,3)\right)\\[5pt]
&\iff t\in[-2,2]\cup[3,7] \, .
\end{align}
Hence, $-2\le|\log_2(x)|\le 2$ or $3\le|\log_2(x)|\le 7$.
If $x\ge1$, then these inequalities become $-2\le\log_2(x)\le2$ (which has the solution $\frac{1}{4}<x\le4$) and $3\le\log_2(x)\le7$ (which has the solution $8\le x\le 128$). So if $x\ge1$, then $\frac{1}{4}\le x\le 4$ or $8\le x\le 128$. This boils down to $1\le x\le 4$ or $8\le x\le128$.
If $0<x<1$, then the inequalities become $-2\le-\log_2(x)\le 2$ (which has solution $\frac{1}{4}\le x\le2$) and $3\le -\log_2(x) \le 7$ (which has solution $\frac{1}{128}\le x\le\frac{1}{8}$). This boils down to $\frac{1}{128}\le x\le\frac{1}{8}$ or $\frac{1}{4}\le x\le1$.
Combining all of these solutions, we find that $\frac{1}{128}\le x\le\frac{1}{8}$ or $\frac{1}{4}\le x\le 4$ or $8\le x\le 128$.
I will give an example of how I solved one of the above inequalities. The rest of them are left as exercises:
\begin{align}
3\le -\log_2(x)\le 7 &\iff -3 \ge \log_2(x) \ge - 7 \\[5pt]
&\iff -7 \le \log_2(x) \le -3 \\[5pt]
&\iff 2^{-7} \le x \le 2^{-3} \\[5pt]
&\iff \frac{1}{128} \le x \le \frac{1}{8} \, .
\end{align}
Finally, there is a simpler way to solve $-2\le|\log_2(x)|\le 2$ or $3\le|\log_2(x)|\le 7$, but it is not obvious. A number $y$ satisfies these inequalities if and only if $\frac{1}{y}$ satisfies them. So once we have the solutions $1\le x \le 4$ or $8 \le x \le 128$, we can easily find the others. Admittedly, I didn't realise this until I solved this inequality the long-winded way.
</s>