# Example of a continuous function that don't have a continuous extension

Give an example of a topological space $$(X,\tau)$$, a subset $$A\subset X$$ that is dense in $$X$$ (i.e., $$\overline{A} = X$$), and a continuous function $$f:A\to\mathbb{R}$$ that cannot be continually extended to $$X$$, that is, a $$f$$ for such do not exist a continuous function $$g:X\to \mathbb{R}$$ such that $$f(x) = g(x)$$ for all $$x\in A$$.

I just proved that if $$f,g:X\to\mathbb{R}$$ are continuous and agree in a dense subset $$A\subset X$$ then they're equal.

I thought in $$X=\mathbb{R}$$ with usual topology and $$A = \mathbb{R}-\{0\} =:\mathbb{R}^*\$$, so I think $$f:\mathbb{R}^*\to\mathbb{R}, f(x) = x^{-1}$$ is a continuous function that cannot be continually extended to $$\mathbb{R}$$. I'm quite sure of this, but I'm stuck in proving it using the definition of continuity in general topological spaces.

Also, I'm quite confused on how this asked example is not a counterexample of what I proved.

• The open intervals form a basis for topology on the real line. A set is open if and only if it contains an open interval around each of these points. Using this definition of open sets you can show that the two different definitions of continuity are actually the same in this case. So you're example will work. And to show it will work you can show it using the usual definition of continuity you're used to in the real numbers. – Melody Apr 7 '19 at 2:09

Define $$f(x)=1/x$$ like you did, and assume you can find a continuous extension $$g : \mathbb{R}\to\mathbb{R}$$. Well this $$g$$ takes a real numbered value at $$0$$, namely $$-\infty < g (0) < \infty$$, and it agrees with $$f$$ at non-zero values.

One definition of continuity is that given a net of points in $$X$$ converging to $$x_0$$ and a function $$g$$, then the images converge to $$g(x_0)$$. Since $$\mathbb{R}$$ is a metric space, we can use sequences instead of nets. But given a sequence of real numbers $$(x_n )_{n=1}^{\infty}$$ converging to $$0$$, the sequence $$(g (x_n))_{n=1}^{\infty}$$ converges to either positive or negative $$\infty$$. So it does not converge to $$g (0)$$. So $$g$$ is not continuous

BTW regarding your question on the results you proved. You proved a result about two functions that were continuous on the entire space, who agree on a dense subset. But the main question of your post is regarding a function who is not assumed to be continuous on the entire space, and comparing it to one that is continuous on the entire space. So the main example is not countering your original result

Using sequences is the easiest way to go, but for a more "topological" proof, to show that no extension of $$f$$ is continuous at $$x=0,$$ we suppose there is one (we still call it $$f$$ for convenience), and we show that there is an $$\epsilon>0$$ so that for any $$\delta >0$$, there is an $$x\in (-\delta,\delta$$), such that$$f(x)>f(0)+\epsilon$$ (or that $$f(x)). Let's do the former.

Now, drawing a picture will make the following obvious:

Take $$\epsilon=1.$$ Then, if $$f(0)+1\le 0$$, then $$\text{any}\ x\in (0,\delta)$$ will do because $$f(x)=1/x>0.$$

If $$f(0)+1> 0$$, all we need do is choose $$x$$ small enough so that $$f(x)=1/x>f(0)+1,$$ which is to say, choose $$x<\min\{\delta, \frac{1}{f(0)+1}\}$$

Another reason: continuous in the whole line implies locally bounded near every point.

And another counterexample based in a different idea: $$\Bbb Q$$ is dense in $$\Bbb R$$ with the usual topology. The function $$f:\Bbb Q\longrightarrow\Bbb R$$ $$f(x) = \begin{cases} 0:& x < \sqrt2,\\ 1:& x > \sqrt2, \end{cases}$$ is continuous (check it) and can't be extended continuously to $$\Bbb R$$.