# Can a nowhere continuous function have a connected graph?

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.

• As Henning points out via example, this is most interesting when $X = \Bbb{R}$ (and possibly where $Y = \Bbb{R}$ too). Jun 25, 2019 at 14:56
• I wonder whether the Conway base 13 function has a connected graph. Jun 25, 2019 at 18:03
• 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, 2019 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. Jun 25, 2019 at 22:22
• @NateEldredge: It turns out that the graph of the base-13 function is totally disconnected. Jun 27, 2019 at 13:09

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}

• Very nice examples. They show how easy is to break some continuity with additional dimensions while retaining enough of it to maintain connectedness of the graph. So I've added another case to the question, $f: \mathbb R \rightarrow \mathbb R$, in which such methods won't work. Do you think a function in this case is possible, like the one that John Hughes is constructing? Jun 25, 2019 at 22:38
• @AdamLatosiński: I am unsure, and getting nowhere myself. I've been trying to figure out whether the graph of the Conway base-13 function is connected, but without success either way. Jun 25, 2019 at 22:54
• Does $y/x(1 - x)$ mean $\frac{y}{x(1 - x)}$ or $\frac{y}{x}(1 - x)$? Jun 26, 2019 at 16:30
• @Bladewood: The former. Jun 26, 2019 at 17:06
• I would rewrite it, the standard interpretation would be the opposite. Jun 26, 2019 at 20:31

Check out this paper:

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

Abstract:

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.

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.)

• Without the last sentence, you might have ended up with $f(x)=0$ ;) Jun 26, 2019 at 6:49
• @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$. Jun 26, 2019 at 7:55
• @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. Jun 26, 2019 at 16:57
• 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. Jun 26, 2019 at 20:35
• Stronger yet, the construction ensures that $f$ is "strongly Darboux" -- i.e., $f([a,b])=\mathbb R$ for every $a<b$. For every $y$ we can show that $G$ intersects $[a,b]\times\{y\}$: WLOG $f(a)\ne y$ and $f(b)\ne y$; now extend $[a,b]\times\{y\}$ with a ray that goes straight upwards or downwards from $(a,y)$ such as to avoid $(a,f(x))$, and a ray that goes straight up or down from $(b,y)$ and avoids $(b,f(b))$. The resulting curve divides $\mathbb R^2$ into two nontrivial open regions, so just like the Jordan curve it intersects $G$. But the vertical parts don't, by construction. Jun 26, 2019 at 21:00

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.

• 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? Jun 25, 2019 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. Jun 25, 2019 at 15:16
• @AdamChalumeau: See "Digression" in which I prove that the graph of $F$ is nice. For $G$, it's presumably tougher.. Jun 25, 2019 at 15:24