After noticing that function $f: \mathbb R\rightarrow \mathbb R $ $$ f(x) = \left\{\begin{array}{l} \sin\frac{1}{x} & \text{for }x\neq 0 \\ 0 &\text{for }x=0 \end{array}\right. $$ has a graph that is a connected set, despite the function not being continuous at $x=0$, I started wondering, doest there exist a function $f: X\rightarrow Y$ that is nowhere continuous, but still has a connected graph?

I would like to consider three cases

  • $X$ and $Y$ being general topological spaces
  • $X$ and $Y$ being Hausdorff spaces
  • ADDED: $X=Y=\mathbb R$

But if you have answer for other, more specific cases, they may be interesting too.

Veronica R. M.
  • 490
  • 4
  • 18
Adam Latosiński
  • 10,265
  • 12
  • 30
  • 2
    As Henning points out via example, this is most interesting when $X = \Bbb{R}$ (and possibly where $Y = \Bbb{R}$ too). – Theo Bendit Jun 25 '19 at 14:56
  • 4
    I wonder whether the [Conway base 13 function](https://en.wikipedia.org/wiki/Conway_base_13_function) has a connected graph. – Nate Eldredge Jun 25 '19 at 18:03
  • 1
    By transfinite induction one can construct a function $f:\mathbb R\to\mathbb R$ whose graph meets every Borel set in the plane whose projection onto the horizontal axis is uncountable. Can such a graph be disconnected? – bof Jun 25 '19 at 19:21
  • @TheoBendit Indeed now I see that case $X=Y=\mathbb R$ is significantly more interesitng. I'll add it as another point. – Adam Latosiński Jun 25 '19 at 22:22
  • @bof: That sounds very promising. This will also make the graph dense in $\mathbb R^2$ (since each open ball is Borel). Then, if the graph is disconnected it will be covered by two disjoint open subsets of $\mathbb R^2$, and the complement of their union is nonempty and closed, hence Borel ... all we now need to argue is that its projection is fat enough. – hmakholm left over Monica Jun 26 '19 at 00:20
  • 2
    @NateEldredge: It turns out that [the graph of the base-13 function is totally disconnected](https://math.stackexchange.com/a/3276016/14366). – hmakholm left over Monica Jun 27 '19 at 13:09

4 Answers4


Here is an example for $\mathbb R^2 \to \mathbb R$:

$$f(x,y) = \begin{cases} y & \text{when }x=0\text{ or }x=1 \\ x & \text{when }x\in(0,1)\text{ and }y=0 \\ 1-x &\text{when }x\in(0,1)\text{ and } y=x(1-x) \\ x(1-x) & \text{when }x\notin\{0,1\}\text{ and } y/x(1-x) \notin\mathbb Q \\ 0 & \text{otherwise} \end{cases} $$

This is easily seen to be everywhere discontinuous. But its graph is path-connected.

A similar but simpler construction, also $\mathbb R^2\to\mathbb R$:

$$ \begin{align} g(1 + r\cos\theta, r\sin\theta) = r & \quad\text{for }r>0,\; \theta\in\mathbb Q\cap[0,\pi] \\ g(r\cos\theta, r\sin\theta) =r & \quad \text{for }r>0,\; \theta\in\mathbb Q\cap[\pi,2\pi] \\ g(x,y) =0 & \quad\text{everywhere else} \end{align} $$

hmakholm left over Monica
  • 276,945
  • 22
  • 401
  • 655

Check out this paper:

F. B. Jones, Totally discontinuous linear functions whose graphs are connected, November 23, (1940).


Cauchy discovered before 1821 that a function satisfying the equation $$ f(x)+f(y)=f(x+y) $$ is either continuous or totally discontinuous. After Hamel showed the existence of a discontinuous function, many mathematicians have concerned themselves with problems arising from the study of such functions. However, the following question seems to have gone unanswered: Since the plane image of such a function (the graph of $y =f(x)$) must either be connected or be totally disconnected, must the function be continuous if its image is connected? The answer is no.

In particular, Theorem 5 presents a nowhere continuous function $f:\Bbb R \rightarrow \Bbb R$ whose graph is connected.

Whether Conway base 13 function is such an example remains unknown. (at least on MSE; see Is the graph of the Conway base 13 function connected?) It turns out the graph of Conway base 13 function is totally disconnected. See this brilliant answer.

YuiTo Cheng
  • 4,337
  • 18
  • 23
  • 57

There is a simple general strategy for many questions of this type, which is to just try to build a counterexample by transfinite induction. Let's first think about what it means for the graph $G$ of a function $f:\mathbb{R}\to\mathbb{R}$ to be disconnected. It means there are open sets $U,V\subset\mathbb{R}^2$ such that $U\cap G$ and $V\cap G$ are both nonempty and together they form a partition of $G$ (we will say $(U,V)$ separates $G$ in that case). So, to make $G$ connected, we just have to one-by-one rule out every such pair $(U,V)$ from separating it.

So, then, here is the construction. Fix an enumeration $(U_\alpha,V_\alpha)_{\alpha<\mathfrak{c}}$ of all pairs of open subsets of $\mathbb{R}^2$. By a transfinite recursion of length $\mathfrak{c}$ we define values of a function $f:\mathbb{R}\to\mathbb{R}$. At the $\alpha$th step, we add a new value of $f$ to prevent $(U_\alpha,V_\alpha)$ from separating the graph of $f$, if necessary. How do we do that? Well, if possible, we define a new value of $f$ such that the corresponding point in the graph $G$ will either be in $U_\alpha\cap V_\alpha$ or not be in $U_\alpha\cup V_\alpha$, so $U_\alpha\cap G$ and $V_\alpha\cap G$ will not partition $G$.

If this is not possible, then $U_\alpha$ and $V_\alpha$ must partition $A\times\mathbb{R}$ where $A\subseteq\mathbb{R}$ is the set of points where we have not yet defined $f$. Since $\mathbb{R}$ is connected, this means we can partition $A$ into sets $B$ and $C$ (both open in $A$) such that $U_\alpha\cap (A\times\mathbb{R})=B\times\mathbb{R}$ and $V_\alpha\cap (A\times\mathbb{R})=C\times\mathbb{R}$. Now since we have defined fewer than $\mathfrak{c}$ values of $f$ so far in this construction, $|\mathbb{R}\setminus A|<\mathfrak{c}$ and in particular $A$ is dense in $\mathbb{R}$. If $B$ were empty, then $U_\alpha$ would have empty interior and thus would be empty, and so $(U_\alpha,V_\alpha)$ can never separate the graph of $f$. A similar conclusion holds if $C$ is empty, so let us assume both $B$ and $C$ are nonempty. It follows that $\overline{B}$ and $\overline{C}$ cannot be disjoint (otherwise they would be a nontrivial partition of $\mathbb{R}$ into closed subsets), so there is a point $x\in\mathbb{R}\setminus A$ that is an accumulation point of both $B$ and $C$. Since $x\not\in A$, we have already defined $f(x)$. Note now that $(x,f(x))\not\in U_\alpha$, since $U_\alpha$ would then contain an open ball around $(x,f(x))$ and thus would intersect $C\times\mathbb{R}$. Similarly, $(x,f(x))\not\in V_\alpha$. Thus $U_\alpha$ and $V_\alpha$ already do not contain the entire graph of $f$, and so we do not need to do anything to prevent them from separating it.

At the end of this construction we will have a partial function $\mathbb{R}\to\mathbb{R}$ such that by construction, its graph is not separated by any pair of open subsets of $\mathbb{R}^2$, and the same is guaranteed to hold for any extension of our function. Extending to a total function, we get a total function $f:\mathbb{R}\to\mathbb{R}$ whose graph is connected. But we can of course arrange in this construction for $f$ to be nowhere continuous; for instance, we could start out by defining $f$ on all the rationals so that the image of every open interval is dense in $\mathbb{R}$. In fact, the construction shows that any partial function $\mathbb{R}\to\mathbb{R}$ defined on a set of cardinality less than $\mathfrak{c}$ can be extended to a total function whose graph is connected. (Or even stronger, you could start with any partial function whose domain omits $\mathfrak{c}$ points from every interval, since that is all you need to guarantee that the set $A$ is dense at each step.)

Eric Wofsey
  • 295,450
  • 24
  • 356
  • 562
  • Without the last sentence, you might have ended up with $f(x)=0$ ;) – Hagen von Eitzen Jun 26 '19 at 06:49
  • 1
    @HagenvonEitzen: There's not actually a need to do anything additional to make the function nowhere continuous. The construction directly implies that that _every Jordan curve_ in the plane will intersect the graph, which includes even very small circles anywhere in the plane. So the graph naturally becomes dense in $\mathbb R^2$. – hmakholm left over Monica Jun 26 '19 at 07:55
  • 1
    @EricWofsey: But whenever you have a Jordan curve, then the set of points inside and outside the curve form a possible pair of open $U_\alpha$ and $V_\alpha$ for your construction. There's no point in $U_\alpha\cap V_\alpha$ one can add to the graph, so your construction will add a point _outside_ $U_\alpha\cup V_\alpha$ to the graph instead instead. But $\mathbb R^2\setminus(U_\alpha\cup V_\alpha)$ are exactly the points on the Jordan curve. – hmakholm left over Monica Jun 26 '19 at 16:57
  • 1
    Even simpler, for every nonempty open $S\subseteq \mathbb R^2$ and $s\in S$, there will be an $\alpha$ such that $(U_\alpha,V_\alpha)=(\mathbb R^2\setminus\{s\},S)$. Then the construction must add a point from $U_\alpha\cap V_\alpha \subseteq S$ to $G$. Since $S$ was arbitrary open, this means that $G$ becomes dense. – hmakholm left over Monica Jun 26 '19 at 20:35
  • 1
    Stronger yet, the construction ensures that $f$ is "strongly Darboux" -- i.e., $f([a,b])=\mathbb R$ for every $a – hmakholm left over Monica Jun 26 '19 at 21:00

Not an answer

Great question, and I don't have an answer for you, but I've got some small thoughts:

By summing up weighted and displaced copies of $f$, you can get discontinuities at many places. For instance, you could write $$ F(x) = \sum_{n \in \Bbb Z} \frac{f(x-n)}{1+n^2} $$ That'll have an $f$-like discontinuity at every integer.

Digression A comment asks whether the graph is still connected. Let me show that it is at $x = 1$ as an example, which should be reasonably compelling for other integer points. (For non-integer points, $F$ is continuous, so we're fine).

Write \begin{align} F(x) &= \frac{1}{2} f(x-1) + \sum_{n\ne 1 \in \Bbb Z} \frac{f(x-n)}{1+n^2}\\ &= \frac{1}{2} f(x-1) + G_1(x) \end{align} where $G_1$ is a function that's continuous at $x = 1$.

Let's look at the graph of $F$ near $1$, say on the interval $(3/4, 5/4)$. It's exactly $$ K = \{ (x, \frac{1}{2} f(x-1) + G_1(x)) \mid 3/4 < x < 5/4 \} $$

Contrast this with the graph of $f$ near $0$, which is $$ H = \{ (x, f(x)) \mid -1/4 < x < 1/4 \} $$ and which we know (from standard calculus books like Spivak) to be connected.

Now look at the function $$ S : K \to H : (x, y) \mapsto (x-1, y - G_1(x)) $$ This is clearly continuous and a bijection (and even extends to a bijection from a (vertical) neighborhood of $K$ to a neighborhood of $H$), so $K$ is also connected.

End of digression

And then for numbers with finite base-2-expansions, you can do the same sort of thing: let $$ G(x) = \sum_{k \in \Bbb Z, k > 0} \frac{1}{2^k} F(2^k x) $$ and that'll have $f$-like discontinuities at all the points with finite base-2 representations, which is a dense set in $\Bbb R$.

But I have a feeling that sliding over to the uncountable-set territory is going to be a lot harder.

John Hughes
  • 88,069
  • 4
  • 68
  • 131
  • This is a good way to get functions which are discontinuous at many points, but are the graph of $F$ and and the graph of $G$ still connected? – Adam Chalumeau Jun 25 '19 at 14:46
  • Well...they could only be disconnected at their points of discontinuity. And (for $F$ at least) at those points the graph is (roughly) the sum of something linear (the derivative approximation) and the graph of $f$; applying a shearing operation gets rid of the linear part, and you've got something a lot like the graph of $f$. I'll add details. – John Hughes Jun 25 '19 at 15:16
  • 1
    @AdamChalumeau: See "Digression" in which I prove that the graph of $F$ is nice. For $G$, it's presumably tougher.. – John Hughes Jun 25 '19 at 15:24