TITLE: Theorem 4.22 from baby Rudin: continuity and connectedness
QUESTION [5 upvotes]: I have some parts that I don't understand from the given proof. 
The theorem is: If $f$ is a continuous mapping of a metric space $X$ in to a metric space $Y$, and if $E$ is a connected subset of $X$, the $f(E)$ is connected.
For the proof we assume on the contrary that $f(E)=A\cup B$, where $A$ and $B$ are nonempty separated subset of $Y$. Then we put $G=E\cap f^{-1}(A)$ and $H=E\cap f^{-1}(B)$  
My questions are:
1) How can I get the intuition to set up like this?
2) Why isn't $G$ just $f^{-1}(A)$ and $H$ just $ f^{-1}(B)$?
We take $f^{-1}$ then $E=f^{-1}(A\cup B)$, then $E=f^{-1}(A) \cup f^{-1}(B)$. I think I definitely missing some important idea or fact.

REPLY [5 votes]: To answer your first question, to get a contradiction by assuming that a separation exists for $f(E)$, we'll need to show that, if this were true, then our assumption that $E$ is connected would be false.  So we need to look at the preimage $f^{-1}(E)$, but we're really only interested in the points $E \cap f^{-1}(E)$.
Ultimately, I think your confusion in both questions is arising from thinking about this mapping as injective, which is not necessarily the case.  Points outside of $E$ could map into $f(E)$.
For example, consider the function $f(x) = \sin(x)$.  Certainly this is continuous, and $[0, \pi/2]$ is a connected subset of $\mathbb{R}$.  Now, $f([0, \pi/2]) = [0, 1]$.  
However, $f^{-1}([0, 1]) = [0, \pi/2] \cup [2\pi,  5\pi/2] \cup \cdots$
The moral of the story is that, when looking at the preimage, you could be getting a lot of other junk that you aren't interested in.