Does a continuous function $f: [0,1] \cup [2,3] \to [5,6]$ exist?

Yes, for example take the constant function $f(x) = 5$

The function you provided is also continuous. Although it may look discontinuous because the graph has two components, continuity is a local property of a function around each point of its domain. And near each point of $[0,1]\cup [2,3]$ your function is continuous. Any jump that appears is outside the domain of the function, and therefore doesn't impact its continuity.

Note that you didn't even need to arrange that $f(1)=f(2)$. It would still be continuous with lines of positive slope on both components. I'm not sure if you arranged the function to match on the endpoints because you thought it was necessary for continuity; it is not.

However the function that you have written is especially nice, because it can be recognized as the restriction of an absolute value function, which is manifestly continuous.

In general, a function is continuous on a domain if it is continuous on each connected component.


Another example is this:

Consider $f: \mathbb{R} \to \mathbb{R}$ given by

$$f(x) = \frac{1}{3}x+5$$ It is continuous on $\mathbb{R}$.

Now restrict it to your domain $[0,1] \cup [2,3]$.

Restricting the domain or the co-domain of a function does not affect its continuity.


The function you have provided is actually continuous. Take $\epsilon$ to be equal to $\delta$ and you will see that the definition of continuity is met at every point in the domain. It looks not continuous at first glance (because the domain is not a connected set), but there is no violation of the definition of continuity.

You will see with that definition that if the function is separately continuous over each connected component of the domain, then it is continuous over the whole domain.