TITLE: Prove: $B=\{x\in \Bbb R\mid x^2\in\Bbb Q\}$ is countable
QUESTION [7 upvotes]: Prove: The set $B=\{x\in \Bbb R\mid x^2\in\Bbb Q\}$ is countable
I have this idea but I'm not sure if it's correct:
We know $\Bbb Q$ is countable so we can list $\Bbb Q$ as $\Bbb Q= \{ q_1,q_2,q_3,\ldots,q_n \mid n \in \Bbb N\}$
On the other hand $x^2=a$  has finite solutions ($0$, $1$, or $2$)
Let $A_i= \{x\mid x^2= q_i, q_i \in \Bbb Q, i \in \Bbb N\}$ following the order of $\Bbb Q$. 
Let $S= \bigcup_{i=1}^\infty A_i  $ And S is a  countable union of countable sets. 
Hence S is countable

REPLY [2 votes]: We can, indeed, use the fact that $\Bbb Q$ is countable. Consider the function $f:\Bbb Q\to\Bbb R$ given by $$f(x)=\begin{cases}\sqrt x & x\ge0\\-\sqrt{-x} & x<0.\end{cases}$$ This can be shown to be one-to-one without too much difficulty, and its range is precisely $B,$ so we're done.