I found this comment in my lecture notes, and it struck me because up until now I simply assumed that continuous functions map closed sets to closed sets.

What are some insightful examples of continuous functions that map closed sets to non-closed sets?

  • 28
    $\begingroup$ $f(x) = \frac1{1+x^2}$ where $x \in \mathbb{R}$ $\endgroup$
    – user17762
    May 21, 2012 at 20:35
  • 4
    $\begingroup$ $f(x) = \text{arc tg}(x)$ for $x\in \mathbb{R}$. $\endgroup$
    – abatkai
    May 21, 2012 at 20:37
  • 5
    $\begingroup$ Let $X$ be $\Bbb R$ with the discrete metric and $Y$ be $\Bbb R$ with its usual metric. Let $f$ be the identity mapping. $\endgroup$ May 21, 2012 at 20:45
  • 9
    $\begingroup$ $f(x) = e^{x}$ on $\mathbb{R}$. $\endgroup$
    – copper.hat
    May 21, 2012 at 20:47
  • 21
    $\begingroup$ Despite continuous functions can map closed sets to non-closed sets, they always send compact sets to compact sets. $\endgroup$
    – Egbert
    May 21, 2012 at 21:54

2 Answers 2


Here’s a small sample of examples.

The graph $G$ of $y=1/x$ is closed in $\Bbb R^2$, and the map $p:\Bbb R^2\to\Bbb R:\langle x,y\rangle\mapsto x$ is continuous, but $p[G]=(\leftarrow,0)\cup(0,\to)$, which is not closed in $\Bbb R$.

The map $\Bbb R\to\Bbb R:x\mapsto e^{-x}$ sends the closed subset $[0,\to)$ of $\Bbb R$ to the non-closed subset $(0,1]$. Other functions with horizontal asymptotes provide similar examples.

If $X$ is any non-closed subset of a space $Y$, the inclusion map $i:X\to Y:x\mapsto x$ gives a trivial example, since $X$ is a closed subset of itself.

Another trivial example is obtained by taking any infinite set $X$, letting $\tau_d$ be the discrete topology on $X$, and letting $\tau$ be any other topology on $X$. The identity map from $\langle X,\tau_d\rangle$ to $\langle X,\tau\rangle$ is automatically continuous. However, there is at least one $x_0\in X$ such that $\{x_0\}\notin\tau$ (i.e., $x_0$ isn’t an isolated point of $\langle X, \tau \rangle$); if $A=X\setminus\{x_0\}$, then $A$ is closed in $\langle X,\tau_d\rangle$ (as is every subset of $X$), but $A$ is not closed in $\langle X,\tau\rangle$.


In addition to the excellent examples presented by Brian, I want to point out what exactly all of these have in common.

The key property that is making these examples work (i.e. closed sets whose images under a continuous function are not closed) is that they're unbounded. If instead, in the special case of real functions, we were dealing with closed and bounded sets, then their images would always be closed (and bounded). This is a result that can be generalized by saying "the image of a compact set under a continuous function is compact".

Here's my attempt at explaining why this is, informally, by restricting ourselves to real functions (functions from $\mathbb{R}$ to $\mathbb{R}$) with the usual Euclidean metric. In this special case, by the Heine-Borel theorem, a set is compact if and only if it is closed and bounded. (In a more general setting we would need to work with the general definition of compactness, which is not quite as intuitive.)

(Warning: what follows is just intended to help build intuition, and doing so by restricting to the special case of real functions, so keep in mind that there is some work to be done in order to formalise the reasoning and generalise it to all topological spaces.)

Intuitively, the only way you can make the image of a set under a function not closed is if, on that set, the function comes arbitrarily close to a certain value but never actually reaches it. (This is because you will not be able to draw any open ball in the codomain around that value—which will be part of the complement of the image—that doesn't contain some points from the image, which implies the complement isn't open and hence the image isn't closed.) Here are some examples of functions, continuous and discontinuous, that exhibit this behaviour:

  • The function $f \colon \mathbb{R} \to \mathbb{R}$ defined as $f(x) = e^x$: e^x

    The image of $\mathbb{R}$ under $f$ is $(0, +\infty)$. This function gets arbitrarily close to $0$ as $x$ tends to $-\infty$, but never attains that value; this is what causes the image to not be closed. This is a continuous function on a closed but unbounded set.

  • The function $f \colon (0, 1) \to \mathbb{R}$ defined as $f(x) = x$: x

    The image here is $(-1, 1)$. The cuplrits for the non-closedness of the image are $-1$ and $1$; again, the function approaches these values but never actually reaches them. This is a continuous function on a non-closed (and in particular, open) and bounded set.

  • The function $f \colon [0, 1] \to \mathbb{R}$ defined as $\displaystyle f(x) = \begin{cases} \displaystyle\frac{1}{e^{x^2}} \quad &\text{if $x \ne 0$} \\ 0 \quad &\text{if $x = 0$} \end{cases}$: 1/e^x^2

    Here the image is $\{0\}\cup [\frac{1}{e}, 1)$. Once again, $f$ approaches 1 but doesn't reach it. This is a discontinuous function on a closed and bounded set.

Now, what are the ways in which a continuous function on a closed set can approach a value without reaching it? If the domain is unbounded, that's easy: just let the function approach a value asymptotically as $x$ tends to $\pm\infty$ (like in our first example, $f(x) = e^x$). Are there any other ways? (Spoiler alert: no!)

If we try something like the third example above, approaching a value from both sides, the continuity of the function will force us to "fill in" the missing image with the value we're approaching:


But this is not specific to closed sets. What about approaching a value towards a point at the boundary of our domain? A key property of a closed set is that it contains all its limit points (in fact, we can even define closed sets by this property), hence the point on the boundary we approach will also be part of the domain. So, our function will also be defined there: which value will it take? Continuity, once again, forces the image at that limit point to be the limit of the images, i.e., the value we were approaching. Therefore this value is included in the image of the domain and thus the latter remains closed.


We have thus (intuitively) shown that the only way to make a continuous function on a closed set produce a non-closed image is to make the domain unbounded. In other words, if a subset of $\mathbb{R}$ is closed and bounded, then the image of that set under a continuous function will also be closed.

Here's a little addendum: the result I cited at the top of this answer said that the image of a closed and bounded set under a continuous real function is closed and bounded, but so far we have only seen the "closed" part.

Again, an intuitive explanation runs along the same lines. For the sake of illustration let's restrict ourselves to intervals. If you have a bounded domain, i.e. "limited horizontal space to draw your graph", and you have to draw a graph from one endpoint to another without lifting your pen, you can only "grow" your function a finite amount. You can't blow off to infinity, because then you would have to "return" from infinity to connect back to the second endpoint, creating a discontinuity (an asymptote):


The fact that the interval is closed is key: this ensures that the function is defined at the endpoints and thus, by continuity, the graph must "connect" to $(a, f(a))$, $(b, f(b))$. Otherwise, if the endpoints weren't included, the function could grow to infinity asymptotically as it approaches $a$ or $b$, as it doesn't need to be defined there. For example, $x \mapsto \frac{1}{x}$ defined on $(0, 1]$ has a vertical asymptote at $0$.

  • $\begingroup$ Your answer deserves more upvotes! It helped me a lot! $\endgroup$
    – Natasha J
    Aug 22, 2021 at 2:07
  • $\begingroup$ +1 for explaining the thought process. Only Heine-Borel may be missing. $\endgroup$ Feb 1, 2022 at 19:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .