Given complete metric spaces $(X,d_{X})$ and $(Y,d_{Y})$, a continuous function $f:X \to Y$, and a compact subset $K \subset f(X)$, I would like to know if it is possible to claim that there exists a compact $F \subset X$ such that $K \subset f(F)$.
It seens to be right in particular cases when I suppose for instance $f$ to be bijective, and both spaces $X=Y=\mathbb{R}$.
Any help and counterexamples would be great.
I only refer to the easier question:
The answer is yes, if $n=1$ and no (i.e., not in general) if $n\ge 2$.
Proof for $n=1$: In this case $f(\mathbb R)$ is a compact and connected set in $\mathbb R$, hence an interval: $f(\mathbb R) = [a,b]$. Now, choose $x,y\in\mathbb R$ such that $f(x) = a$ and $f(y) = b$. Then, by the intermediate value theorem, $f([x,y]) = [a,b] = f(\mathbb R)$.
Counter example for $n=2$. Define $\phi(x) = 4\arctan(x)$ and set $$ f(x) = \begin{cases} (1+\cos(\phi(x)-\pi),\sin(\phi(x)-\pi)) &\text{if }x\ge 0,\\ (-1+\cos\phi(x),\sin\phi(x)) &\text{if }x< 0. \end{cases} $$ Then $f$ is obviously continuous and $f(\mathbb R) = C_1\cup C_{-1}$ is compact, where $C_t$ denotes the circle with center $(t,0)$ and radius $1$. But there can never be a compact $K\subset\mathbb R$ such that $f(K) = f(\mathbb R)$ since $f$ is injective.