I have recently started learning analysis, and I’ve gotten to the "set theory" part. I'm currently struggling with the problem of proving that $[0,1)$ and $\mathbb{R}$ have the same cardinality.
Earlier, I already figured out what a bijection $(0,1) \to \mathbb{R}$ looks like:
$$k(x)=\tan\left(\pi\left(x-\frac{1}{2}\right)\right)$$ So I decided to use this function to find a bijection from $[0,1)$ to $\mathbb{R}$ and show that they have the same cardinality.
My proof:
Since $(0,1)$ is an uncountable set (as well as infinite), we can choose a countable subset of it, like this:
$$A=\left\{\frac{1}{2},\frac{1}{3},\dots,\frac{1}{n}\right\}, \quad n \in \mathbb{N},\ n \geq 2$$
(Of course, this set is not finite.) Clearly, $A \subset (0,1)$.
The same applies to $\mathbb{R}$: we also have a subset $B = \{y_1, y_2, \dots, y_n\} \subset \mathbb{R}$, where each $y_n = k\left(\frac{1}{n}\right)$. So $A \to B$ is a bijection because $k$ is a bijection.
Similarly, we can take a set $C = \{x_1, x_2, \dots, x_n\} \subset (0,1)$ such that $k(x_n) = \frac{1}{n}$. Then $C \to A$ is also a bijection.
Since $\text{card}(A) = \text{card}(B)$ and $\text{card}(A) = \text{card}(C)$, it follows that $\text{card}(B) = \text{card}(C)$.
- If $x \in C$, then $f(x) = y_n$ where $k(x) = \frac{1}{n}$ and $y_n = k\left(\frac{1}{n}\right)$.
- $f(0) = \frac{1}{2}$, and for other values of the form $x = \frac{1}{n}$ with $n \geq 2$, set $f\left(\frac{1}{n}\right) = \frac{1}{n+1}$.
- Otherwise, use $f(x) = k(x)$.
So: $$ f(x)= \begin{cases} y, & \text{when } k(x) = \frac{1}{n} \text{ and } k\left(\frac{1}{n}\right)= y, \\ \frac{1}{2}, & \text{if } x=0 \\ \frac{1}{n+1}, & \text{if } x = \frac{1}{n} \\ k(x), & \text{otherwise} \end{cases} \quad n \in \mathbb{N},\ n \geq 2 $$
Since we have constructed a bijection from $[0,1)$ to $\mathbb{R}$, we can conclude that $\text{card}([0,1)) = \text{card}(\mathbb{R})$.
I would like to know if my reasoning is correct and if the final answer is mathematically valid. I tried to construct an explicit bijection $f : [0,1) \to \mathbb{R}$, and I think it works.
But I need a second opinion: is the function $f$ really a bijection? Are there any mistakes or problems in my argument or in the definition of $f$? I would really appreciate some feedback.