Can a continuous function have discontinuities?

The function $ f(x) = \frac{1}{x} $ is continuous on its domain. It is not defined at 0, so its domain is $ \mathbb{R} - \{0\} $, so it's not that $ f $ is discontinuous at 0, rather it's simply not defined there. In fact there is a stronger result, if you had a function $ g: \mathbb R \to \mathbb R $ such that $ g(x) = f(x) $ on the domain of $ f $, then $ g $ is discontinuous at 0. Essentially, $ f $ itself is continuous because it is not defined at 0, but if you try and assign a value at 0, you will get a discontinuity there.


The definition of continuity is for points in domain of f. The basic definition for continuity of real valued functions is

$f$ is continuous at $y\in Dom(f) $ iff $$(\forall\varepsilon >0)(\exists \delta>0)(|x-y|<\delta \Rightarrow |f(x)-f(y)|<\varepsilon )$$ as you can see the definition doesn't make sense if $y\notin Dom(f)$ because there is no $f(y)$

So, your function $f(x)=\frac{1}{x}$ is continuous, because 0 is not in the domain.


There are actually some important subtleties that are being missed here, which I would like to highlight:

In order to define a function, you need to specify three pieces of data: the domain of the function, the codomain of the function, and a way of relating elements of the domain to elements of the codomain.[1] In the case of your function $f(x) = \frac{1}{x}$, you've specified the relation, but have not specified either the domain or codomain. My guess is that you are taking a class where it is assumed throughout that all functions have some domain in the real numbers, and have codomain equal to $\mathbb{R}$. Assuming that this is the case, the function that you are working with can be more clearly specified as $$ f : \mathbb{R}\setminus\{0\} \to \mathbb{R} : x \mapsto \frac{1}{x}. \tag{1}$$

When working with functions of real numbers, a common way of defining continuity is the "standard" $\varepsilon$-$\delta$ definition:

Definition: Suppose that $X \subseteq \mathbb{R}$ and that $f : X \to \mathbb{R}$. We say that $f$ is continuous at a point $a \in X$ if for all $\varepsilon > 0$ there exists some $\delta > 0$ such that if $x \in X$ and $|x - a| < \delta$, then $|f(x) - f(a)| < \varepsilon$. We say that $f$ is continuous on its domain if $f$ is continuous at all of the points of $X$, i.e. $f$ is continuous at $a$ for all $a\in X$.

Note that there are two notions of continuity here: continuity at a point, and continuity on some domain. Typically, when we say that $f$ is continuous, we mean that it is continuous on its domain. Hence when we say that the function $f$ defined in (1) is continuous, we mean that it is continuous on the set $\mathbb{R}\setminus \{0\}$ (as an exercise, you should see if you can confirm this from the definition of continuity, above).

I suspect that part of the confusion here stems from another common definition of continuity that is seen in introductory calculus classes. In such classes, limits are dealt with somewhat informally, then the following definition is given:

Definition: A function $f$ is continuous at $a\in\mathbb{R}$ if

  • $\lim_{x\to a} f(x)$ exists (which occurs if and only if $\lim_{x\to a^+} f(x) = \lim_{x\to a^-} f(x)$, assuming that both of these limits exist),
  • $f(a)$ is defined, and
  • $\lim_{x\to a} f(x) = f(a)$.

We say that $f$ is continuous on its domain (or simply continuous) if it is continuous at every point in the domain.

It can be shown that this definition is essentially the same as the one given above, once a formal definition of a limit is given and some of the problems with defining the domain of $f$ are dealt with. However, this less formal treatment of continuity can lead to some confusion.

In this case, it appears that the left- and right-hand limits at zero disagree, hence it is tempting to assert that the function is discontinuous at zero. Indeed, if we want to discuss continuity at a point, it is possible to argue that $f$ is not continuous at zero because it is not defined there (though this argument is rather vacuous, in the formal sense of the word). On the other hand, $f$ is continuous (on its domain), since it is continuous at every point in $\mathbb{R}\setminus\{0\}$. Hence it is entirely reasonable to say that $f$ is continuous.


[1] More formally, a relation is a subset of the Cartesian product of two sets. A function $f$ from $X$ to $Y$ is a special kind of relation which satisfies the property that $$ (x,y), (x,y') \in f \iff y = y'. $$ Don't worry too much about this footnote—again, the take-away message is that you need a domain $X$, a codomain $Y$, and a unique way of relating elements of $X$ to elements of $Y$.