Let A be closed subset of the real numbers, then $\{ |x|: x\in A \}$ is closed I'm facing the next problem from the book: A First Course in Real Analysis by Sterling Berberian in the page 64, ex 5.

If $A$ is a closed subset of $\mathbb{R}$, prove that each of the following sets is also closed.
  $-A= \{ -x : x\in A \}$, $B= \{ |x| : x\in A \}$ and $C= \{ x^2 : x\in A \}$

I am confident of my proof for the first set. However
for the second set, I took a sequence $y_n\in B$ such that $y_n \rightarrow p\in R$. For $B$ to be closed I want to show that $p\in B$. They hint me, that I should make use of Weierstrass-Bolzano theorem.
So since $y_n$ is convergent then it is bounded, plus $y_n=|x_n|$ for $x_n \in A$. So from here I want to take a subsequence $y_{n_{k}}=x_{n_{k}}\geq0$ that of course will be convergent to $p$.
Now, using absolute value definition, 
$$y_n=|x_n|=
    \begin{cases}
      x_n, & \text{if } x_n\geq 0 \\
      -x_n, & \text{if } x_n<0
    \end{cases}$$
So if I take the positive subsequence $y_{n_{k}}=x_{n_{k}}\geq 0, (\forall {n_{k}}\in \mathbb{N}) $, we'll have convergence to $p$ of a sequence of $A$ , so $p\in A$ ($A$ is closed) and therefore $|p|=p\in B$.
Can I get your opinion? I feel there is something flawed with this, and I can't find the argument as to why.
 A: For the first, $f(x) = -x$ is a homeomorphism of $\mathbb{R}$ (it is its own inverse). So $f$ is a closed map and $f[A] = \{-x : x \in A\}$ is closed when $A$ is closed.
For the others we can use a variation of this idea:
If $f: X \to Y$ is a function and $f|_{A_1}: A_1 \to Y$ and $f|_{A_2}: A_2 \to Y$ are both closed maps and $A_1 \cup A_2 = X$ and $A_1,A_2$ are both closed in $X$, then $f$ is a closed map. This holds because when $C$ is closed in $X$, $A_i \cap C$ is closed in $A_i$, $i=1,2$) and so $f[C] = (f|_{A_1})[A_1 \cap C] \cup (f|_{A_2})[A_2 \cap C]$ is closed in $Y$, as the union of two closed sets.
For the second, apply this to $Y = A_1 = [0,\infty)$, $f|_{A_1}(x)=x$ is a homeomorphism (hence closed), $A_2 = (-\infty,0]$ and $f_{A_2}(x) = -x$ (ditto), so that $f(x) = |x|$ on the reals. 
For the third use the same $Y$, $A_1, A_2$ and note that $f$ restricted to each $A_i$ is a homeomorphism in both cases (with $x \to \sqrt{x}$ or $x \to -\sqrt{x}$ as inverse resp.). So $|x|$ and $x^2$ are both closed maps which is what was to be shown.
A: It is not correct. You can't say that $y_{n_k}=x_{n_k}$. Imagine, for instance, that each $x_n$ is negative.
However, since there are infinitely many natural numbers either $y_n=x_n$ infinitely many times or $y_n=-x_n$ infinitely many times. If, for intance, $y_n=x_n$ infinitely many times, them, since $\lim_{n\to\infty}y_n=p$, if $n_k$ is the $k$th natural such that $x_{n_k}\geqslant0$, $\lim_{k\to\infty}y_{n_k}=p$ and therefore $\lim_{k\to\infty}x_{n_k}=p$. Since $A$ is closed, $p\in A$ and so $p\in B$.
The case in which $y_n=-x_n$ infinitely many times is similar.
