A characterization of functions from $\mathbb R^n$ to $\mathbb R^m$ which are continuous

Greets

I came up the other day with the following question: Is it true that $f:\mathbb{R}^n\longrightarrow{\mathbb{R}^m}$ is continuous if and only if $f$ maps compact sets onto compact sets and maps connected sets onto connected sets?

I'm having trouble showing the "if", and I haven't found a counterexample to this part, so I would appreciate ideas to prove or disprove this.

Thanks

-
See math.stackexchange.com/questions/4412/… : possible duplicate? –  amWhy Oct 24 '12 at 23:00
umm ok @amWhy, am I supposed to delete the question then? –  Camilo Arosemena Oct 24 '12 at 23:11
@amWhy: I don't think it is a duplicate. That question is asking about connected compact sets. This one is asking about connected sets and compact sets (separately). –  Dejan Govc Oct 24 '12 at 23:14
@Dejan - certainly, it's not an exact duplicate, so I wouldn't close or delete it, for the reasons you mention. But the link - and its comments and answers might offer some insight into this problem. –  amWhy Oct 24 '12 at 23:20
I feel like this could be generalized in terms of the spaces for an easier proof. –  toypajme Dec 19 '12 at 4:51

Suppose $f$ has your property but is discontinuous at $x=a$. Now for each $\delta > 0$, $f([a-\delta, a+\delta])$ is a connected compact set, and thus is an interval containing $f(a)$. Moreover since $f$ is discontinuous at $x=a$ there must be some $c \ne f(a)$ such that $f([a-\delta,a+\delta])$ contains both $f(a)$ and $c$ (and, since it's an interval, everything in between) for all $\delta > 0$. Then there is a sequence $x_n$ such that $|x_n - a| < 1/n$ and $f(x_n) = (1 - 1/n) c + (1/n) f(a)$. Then $K = \{a\} \cup \{x_n: n \in {\mathbb N}\}$ is a compact set, $c$ is a limit point of $f(K)$, but $c \notin f(K)$, contradiction.

EDIT: The question for functions $f$ from ${\mathbb R}^n$ to ${\mathbb R}^m$ also seems interesting. Suppose such an $f$ maps compact sets to compact sets and connected sets to connected sets, but is discontinuous at $a$. Let $B_\delta(p)$ be the closed ball of radius $\delta$ centred at $p$ and $S_\delta(p)$ the sphere of radius $\delta$ centred at $p$ (in either ${\mathbb R}^n$ or ${\mathbb R}^m$ depending on the context). There is $\epsilon > 0$ such that for all $\delta > 0$, $f(B_\delta(a))$ is not contained in $B_\epsilon(f(a))$. For every $r \in (0,\epsilon)$, since $f(B_\delta(a))$ is connected, $f(B_\delta(a)) \cap S_r(f(a))$ must be nonempty. In particular we can take $x_n$ with $\|x_n - a\| \le 1/n$ and $\|f(x_n) - f(a)\| = (1-1/n) \epsilon$. Again we get a contradiction, taking $K = \{a\} \cup \{x_n: n \in {\mathbb N}\}$.

-
thanks a lot for your answer –  Camilo Arosemena Oct 24 '12 at 23:48
the contradiction is gotten because $(f(x_n))_{n\in{\mathbb{N}}}$ has a convergent subsequence? –  Camilo Arosemena Oct 25 '12 at 0:54
In the ${\mathbb R} \to {\mathbb R}$ version, $f(x_n) \to c$. In the ${\mathbb R}^n \to {\mathbb R}^m$ version, $\|f(x_n) - f(a)\| \to \epsilon$ but no $y \in f(K)$ has $\|y - f(a)\| = \epsilon$. –  Robert Israel Oct 25 '12 at 1:17
but we could use the same argument as in the case $\mathbb{R}\rightarrow{\mathbb{R}}$ usign the fact of the convergent subsequence –  Camilo Arosemena Oct 25 '12 at 1:39
I tink it should be "...and thus an interval containing $f(a)$..." –  leo Dec 18 '12 at 23:08

Suppose $f:\mathbb{R}^n\longrightarrow{\mathbb{R}^m}$ sends connected sets onto connected sets and compact sets onto compact sets. We want to show $f$ is continuous. Suppose not,then there is $a\in{R}$ and $\epsilon>0$ such that for every $n\in{N}$ there is $x_n\in{B_{\frac{1}{n}}(a)}$ with $||f(x_n)-f(a)||>\epsilon$, since $f(\overline{B_{\frac{1}{n}}(a)})$ is connected and compact we must have that $(\overline{B_{\epsilon}(a)}-{B_{\frac{\epsilon}{2}}(a)})\cap{f(\overline{B_{\frac{1}{n}}(a)})}\neq{\emptyset}$ for all $n>1$, then $\{f(\overline{B_{\frac{1}{n}}(a)})\}_{n\in{\mathbb{N}}}\cup{\{\overline{B_{\epsilon}(f(a))}-{B_{\frac{\epsilon}{2}}(f(a))}\}}$ is a family of closed sets with a bounded element and the finite intersection property, then $(\bigcap_{n_\in{\mathbb{N}}}f(\overline{B_{\frac{1}{n}}(a)}))\cap{(\overline{B_{\epsilon}(f(a))}-{B_{\frac{\epsilon}{2}}(f(a))})}\neq{\emptyset}$, then there is $b\in{\bigcap_{n_\in{\mathbb{N}}}f(\overline{B_{\frac{1}{n}}(a)})}$ with $\frac{\epsilon}{2}<{||b-f(a)||}\leq{\epsilon}$, but we have that $\bigcap_{n_\in{\mathbb{N}}}(\overline{B_{\frac{1}{n}}(a)}))=\{a\}$, so $\bigcap_{n_\in{\mathbb{N}}}f(\overline{B_{\frac{1}{n}}(a)}))=\{f(a)\}$.A Contradiction.Hence $f$ must be continuous.