<s>[INST] Solve the equation $\lfloor x^2\rfloor-3\lfloor x \rfloor +2=0$ 
Solve the equation
$$
\lfloor x^2\rfloor-3\lfloor x \rfloor +2=0
$$
where $\lfloor x\rfloor $ denotes floor function.

My Attempt:
Let $x = n+f$, where $n= \lfloor x \rfloor \in \mathbb{Z} $, $f=x-\lfloor x \rfloor = \{x\} $, and $0\leq f<1$. Then using $\lfloor n+f \rfloor = n$ gives us
$$
\begin{align}
\lfloor (n+f)^2 \rfloor -3 \lfloor n+f \rfloor +2 &= 0\\
n^2+\lfloor f^2+2nf \rfloor -3n+2 &= 0
\end{align}
$$
How can I solve the equation from here?
 [/INST] Note that if $x\lt0$, then $\lfloor x^2\rfloor-3\lfloor x\rfloor+2\ge5$, so any solution $x=n+f$ with $0\le f\lt1$ must have $n\ge0$.  Picking up at the OP's equation $n^2+\lfloor f^2+2nf\rfloor-3n+2=0$ and letting $r$ denote the non-negative integer $\lfloor f^2+2nf\rfloor$, we find
$$(2n-3)^2=1-4r$$
Thus $r$ must be $0$, which implies $(2n-3)^2=1$, so that $n=1$ or $2$.
If $n=1$, then $r=0$ means $f^2+2f\lt1$, or $(f+1)^2\lt2$, and thus $0\le f\lt\sqrt2-1$, so that $1\le x\lt\sqrt2$.
If $n=2$, then $r=0$ means $f^2+4f\lt1$, or $(f+2)^2\lt5$, and thus $0\le f\lt\sqrt5-2$, so that $2\le x\lt\sqrt5$.
</s>