Skip to main content

Section 3.2 Continuous functions

Note: 2–2.5 lectures

You undoubtedly heard of continuous functions in your schooling. A high-school criterion for this concept is that a function is continuous if we can draw its graph without lifting the pen from the paper. While that intuitive concept may be useful in simple situations, we require rigor. The following definition took three great mathematicians (Bolzano, Cauchy, and finally Weierstrass) to get correctly and its final form dates only to the late 1800s.

Subsection 3.2.1 Definition and basic properties

Definition 3.2.1.

Let \(S \subset \R\text{,}\) \(c \in S\text{,}\) and let \(f \colon S \to \R\) be a function. We say that \(f\) is continuous at \(c\) if for every \(\epsilon > 0\) there is a \(\delta > 0\) such that whenever \(x \in S\) and \(\abs{x-c} < \delta\text{,}\) then \(\abs{f(x)-f(c)} < \epsilon\text{.}\)

When \(f \colon S \to \R\) is continuous at all \(c \in S\text{,}\) then we simply say \(f\) is a continuous function.


Figure 3.2. For \(\abs{x-c} < \delta\text{,}\) the graph of \(f(x)\) should be within the gray region.

If \(f\) is continuous for all \(c \in A\text{,}\) we say \(f\) is continuous on \(A \subset S\). A straightforward exercise (Exercise 3.2.7) shows that this implies that \(f|_A\) is continuous, although the converse does not hold.

Continuity may be the most important definition to understand in analysis, and it is not an easy one. See Figure 3.2. Note that \(\delta\) not only depends on \(\epsilon\text{,}\) but also on \(c\text{;}\) we need not pick one \(\delta\) for all \(c \in S\text{.}\) It is no accident that the definition of continuity is similar to the definition of a limit of a function. The main feature of continuous functions is that these are precisely the functions that behave nicely with limits.

Proof.

We start with the first item. Suppose \(c\) is not a cluster point of \(S\text{.}\) Then there exists a \(\delta > 0\) such that \(S \cap (c-\delta,c+\delta) = \{ c \}\text{.}\) For any \(\epsilon > 0\text{,}\) simply pick this given \(\delta\text{.}\) The only \(x \in S\) such that \(\abs{x-c} < \delta\) is \(x=c\text{.}\) Then \(\abs{f(x)-f(c)} = \abs{f(c)-f(c)} = 0 < \epsilon\text{.}\)

Let us move to the second item. Suppose \(c\) is a cluster point of \(S\text{.}\) Let us first suppose that \(\lim_{x\to c} f(x) = f(c)\text{.}\) Then for every \(\epsilon > 0\text{,}\) there is a \(\delta > 0\) such that if \(x \in S \setminus \{ c \}\) and \(\abs{x-c} < \delta\text{,}\) then \(\abs{f(x)-f(c)} < \epsilon\text{.}\) Also \(\abs{f(c)-f(c)} = 0 < \epsilon\text{,}\) so the definition of continuity at \(c\) is satisfied. On the other hand, suppose \(f\) is continuous at \(c\text{.}\) For every \(\epsilon > 0\text{,}\) there exists a \(\delta > 0\) such that for \(x \in S\) where \(\abs{x-c} < \delta\text{,}\) we have \(\abs{f(x)-f(c)} < \epsilon\text{.}\) Then the statement is, of course, still true if \(x \in S \setminus \{ c \} \subset S\text{.}\) Therefore, \(\lim_{x\to c} f(x) = f(c)\text{.}\)

For the third item, first suppose \(f\) is continuous at \(c\text{.}\) Let \(\{ x_n \}\) be a sequence such that \(x_n \in S\) and \(\lim\, x_n = c\text{.}\) Let \(\epsilon > 0\) be given. Find a \(\delta > 0\) such that \(\abs{f(x)-f(c)} < \epsilon\) for all \(x \in S\) where \(\abs{x-c} < \delta\text{.}\) Find an \(M \in \N\) such that for \(n \geq M\text{,}\) we have \(\abs{x_n-c} < \delta\text{.}\) Then for \(n \geq M\text{,}\) we have that \(\abs{f(x_n)-f(c)} < \epsilon\text{,}\) so \(\bigl\{ f(x_n) \bigr\}\) converges to \(f(c)\text{.}\)

We prove the other direction of the third item by contrapositive. Suppose \(f\) is not continuous at \(c\text{.}\) Then there exists an \(\epsilon > 0\) such that for every \(\delta > 0\text{,}\) there exists an \(x \in S\) such that \(\abs{x-c} < \delta\) and \(\abs{f(x)-f(c)} \geq \epsilon\text{.}\) Let us define a sequence \(\{ x_n \}\) as follows. Let \(x_n \in S\) be such that \(\abs{x_n-c} < \nicefrac{1}{n}\) and \(\abs{f(x_n)-f(c)} \geq \epsilon\text{.}\) Now \(\{ x_n \}\) is a sequence of numbers in \(S\) such that \(\lim\, x_n = c\) and such that \(\abs{f(x_n)-f(c)} \geq \epsilon\) for all \(n \in \N\text{.}\) Thus \(\{ f(x_n) \}\) does not converge to \(f(c)\text{.}\) It may or may not converge, but it definitely does not converge to \(f(c)\text{.}\)

The last item in the proposition is particularly powerful. It allows us to quickly apply what we know about limits of sequences to continuous functions and even to prove that certain functions are continuous. It can also be strengthened, see Exercise 3.2.13.

Example 3.2.3.

The function \(f \colon (0,\infty) \to \R\) defined by \(f(x) := \nicefrac{1}{x}\) is continuous.

Proof: Fix \(c \in (0,\infty)\text{.}\) Let \(\{ x_n \}\) be a sequence in \((0,\infty)\) such that \(\lim\, x_n = c\text{.}\) Then we know that

\begin{equation*} f(c) = \frac{1}{c} = \frac{1}{\lim\, x_n} = \lim_{n \to \infty} \frac{1}{x_n} = \lim_{n \to \infty} f(x_n) . \end{equation*}

Thus \(f\) is continuous at \(c\text{.}\) As \(f\) is continuous at all \(c \in (0,\infty)\text{,}\) \(f\) is continuous.

We have previously shown \(\lim_{x \to c} x^2 = c^2\) directly. Therefore the function \(x^2\) is continuous. We can use the continuity of algebraic operations with respect to limits of sequences, which we proved in the previous chapter, to prove a much more general result.

Proof.

Fix \(c \in \R\text{.}\) Let \(\{ x_n \}\) be a sequence such that \(\lim\, x_n = c\text{.}\) Then

\begin{equation*} \begin{split} f(c) &= a_d c^d + a_{d-1} c^{d-1} + \cdots + a_1 c + a_0 \\ &= a_d {(\lim\, x_n)}^d + a_{d-1} {(\lim\, x_n)}^{d-1} + \cdots + a_1 (\lim\, x_n) + a_0 \\ & = \lim_{n \to \infty} \left( a_d x_n^d + a_{d-1} x_n^{d-1} + \cdots + a_1 x_n + a_0 \right) = \lim_{n \to \infty} f(x_n) . \end{split} \end{equation*}

Thus \(f\) is continuous at \(c\text{.}\) As \(f\) is continuous at all \(c \in \R\text{,}\) \(f\) is continuous.

By similar reasoning, or by appealing to Corollary 3.1.12, we can prove the following proposition. The proof is left as an exercise.

Example 3.2.6.

The functions \(\sin(x)\) and \(\cos(x)\) are continuous. In the following computations we use the sum-to-product trigonometric identities. We also use the simple facts that \(\abs{\sin(x)} \leq \abs{x}\text{,}\) \(\abs{\cos(x)} \leq 1\text{,}\) and \(\abs{\sin(x)} \leq 1\text{.}\)

\begin{equation*} \begin{split} \abs{\sin(x)-\sin(c)} & = \abs{ 2 \sin \left( \frac{x-c}{2} \right) \cos \left( \frac{x+c}{2} \right) } \\ & = 2 \abs{ \sin \left( \frac{x-c}{2} \right) } \abs{ \cos \left( \frac{x+c}{2} \right) } \\ & \leq 2 \abs{ \sin \left( \frac{x-c}{2} \right) } \\ & \leq 2 \abs{ \frac{x-c}{2} } = \abs{x-c} \end{split} \end{equation*}
\begin{equation*} \begin{split} \abs{\cos(x)-\cos(c)} & = \abs{ -2 \sin \left( \frac{x-c}{2} \right) \sin \left( \frac{x+c}{2} \right) } \\ & = 2 \abs{ \sin \left( \frac{x-c}{2} \right) } \abs{ \sin \left( \frac{x+c}{2} \right) } \\ & \leq 2 \abs{ \sin \left( \frac{x-c}{2} \right) } \\ & \leq 2 \abs{ \frac{x-c}{2} } = \abs{x-c} \end{split} \end{equation*}

The claim that \(\sin\) and \(\cos\) are continuous follows by taking an arbitrary sequence \(\{ x_n \}\) converging to \(c\text{,}\) or by applying the definition of continuity directly. Details are left to the reader.

Subsection 3.2.2 Composition of continuous functions

You probably already realized that one of the basic tools in constructing complicated functions out of simple ones is composition. Recall that for two functions \(f\) and \(g\text{,}\) the composition \(f \circ g\) is defined by \((f \circ g)(x) := f\bigl(g(x)\bigr)\text{.}\) A composition of continuous functions is again continuous.

Proof.

Let \(\{ x_n \}\) be a sequence in \(A\) such that \(\lim\, x_n = c\text{.}\) As \(g\) is continuous at \(c\text{,}\) we have \(\bigl\{ g(x_n) \bigr\}\) converges to \(g(c)\text{.}\) As \(f\) is continuous at \(g(c)\text{,}\) we have \(\bigl\{ f\bigl(g(x_n)\bigr) \bigr\}\) converges to \(f\bigl(g(c)\bigr)\text{.}\) Thus \(f \circ g\) is continuous at \(c\text{.}\)

Example 3.2.8.

Claim: \({\bigl(\sin(\nicefrac{1}{x})\bigr)}^2\) is a continuous function on \((0,\infty)\text{.}\)

Proof: The function \(\nicefrac{1}{x}\) is continuous on \((0,\infty)\) and \(\sin(x)\) is continuous on \((0,\infty)\) (actually on \(\R\text{,}\) but \((0,\infty)\) is the range for \(\nicefrac{1}{x}\)). Hence the composition \(\sin(\nicefrac{1}{x})\) is continuous. Also, \(x^2\) is continuous on the interval \((-1,1)\) (the range of \(\sin\)). Thus the composition \({\bigl(\sin(\nicefrac{1}{x})\bigr)}^2\) is continuous on \((0,\infty)\text{.}\)

Subsection 3.2.3 Discontinuous functions

When \(f\) is not continuous at \(c\text{,}\) we say \(f\) is discontinuous at \(c\text{,}\) or that it has a discontinuity at \(c\text{.}\) The following proposition is a useful test and follows immediately from third item of Proposition 3.2.2.

Again, saying that \(\bigl\{ f(x_n) \bigr\}\) does not converge to \(f(c)\) means that it either does not converge at all, or it converges to something other than \(f(c)\text{.}\)

Example 3.2.10.

The function \(f \colon \R \to \R\) defined by

\begin{equation*} f(x) := \begin{cases} -1 & \text{if } x < 0, \\ 1 & \text{if } x \geq 0, \end{cases} \end{equation*}

is not continuous at 0.

Proof: Take the sequence \(\{ - \nicefrac{1}{n} \}\text{,}\) which converges to 0. Then \(f(-\nicefrac{1}{n}) = -1\) for every \(n\text{,}\) and so \(\lim\, f(-\nicefrac{1}{n}) = -1\text{,}\) but \(f(0) = 1\text{.}\) Thus the function is not continuous at 0. See Figure 3.3.


Figure 3.3. Graph of the jump discontinuity. The values of \(f(-\nicefrac{1}{n})\) and \(f(0)\) are marked as black dots.

Notice that \(f(\nicefrac{1}{n}) = 1\) for all \(n \in \N\text{.}\) Hence, \(\lim \, f(\nicefrac{1}{n}) = f(0) = 1\text{.}\) So \(\bigl\{ f(x_n) \bigr\}\) may converge to \(f(0)\) for some specific sequence \(\{ x_n \}\) going to 0, despite the function being discontinuous at 0.

Finally, consider \(f\Bigl(\frac{{(-1)}^n}{n}\Bigr) = {(-1)}^n\text{.}\) This sequence diverges.

Example 3.2.11.

For an extreme example, take the so-called Dirichlet function 1 .

\begin{equation*} f(x) := \begin{cases} 1 & \text{if } x \text{ is rational,} \\ 0 & \text{if } x \text{ is irrational.} \end{cases} \end{equation*}

The function \(f\) is discontinuous at all \(c \in \R\text{.}\)

Proof: Suppose \(c\) is rational. Take a sequence \(\{ x_n \}\) of irrational numbers such that \(\lim\, x_n = c\) (why can we?). Then \(f(x_n) = 0\) and so \(\lim\, f(x_n) = 0\text{,}\) but \(f(c) = 1\text{.}\) If \(c\) is irrational, take a sequence of rational numbers \(\{ x_n \}\) that converges to \(c\) (why can we?). Then \(\lim\, f(x_n) = 1\text{,}\) but \(f(c) = 0\text{.}\)

Let us test the limits of our intuition. Can there exist a function continuous at all irrational numbers, but discontinuous at all rational numbers? There are rational numbers arbitrarily close to any irrational number. Perhaps strangely, the answer is yes, such a function exists. The following example is called the Thomae function 3  or the popcorn function.

Example 3.2.12.

Define \(f \colon (0,1) \to \R\) as

\begin{equation*} f(x) := \begin{cases} \nicefrac{1}{k} & \text{if } x=\nicefrac{m}{k}, \text{ where } m,k \in \N \text{ and } m \text{ and } k \text{ have no common divisors,} \\ 0 & \text{if } x \text{ is irrational.} \end{cases} \end{equation*}

See the graph of \(f\) in Figure 3.4. We claim that \(f\) is continuous at all irrational \(c\) and discontinuous at all rational \(c\text{.}\)


Figure 3.4. Graph of the “popcorn function.”

Proof: Suppose \(c = \nicefrac{m}{k}\) is rational. Take a sequence of irrational numbers \(\{ x_n \}\) such that \(\lim\, x_n = c\text{.}\) Then \(\lim\, f(x_n) = \lim \, 0 = 0\text{,}\) but \(f(c) = \nicefrac{1}{k} \not= 0\text{.}\) So \(f\) is discontinuous at \(c\text{.}\)

Now let \(c\) be irrational, so \(f(c) = 0\text{.}\) Take a sequence \(\{ x_n \}\) in \((0,1)\) such that \(\lim\, x_n = c\text{.}\) Given \(\epsilon > 0\text{,}\) find \(K \in \N\) such that \(\nicefrac{1}{K} < \epsilon\) by the Archimedean property. If \(\nicefrac{m}{k} \in (0,1)\) is in lowest terms (no common divisors), then \(0 < m < k\text{.}\) So there are only finitely many rational numbers in \((0,1)\) whose denominator \(k\) in lowest terms is less than \(K\text{.}\) As \(\lim\, x_n = c\text{,}\) every number not equal to \(c\) can appear at most finitely many times in \(\{ x_n \}\text{.}\) Hence, there is an \(M\) such that for \(n \geq M\text{,}\) all the numbers \(x_n\) that are rational have a denominator larger than or equal to \(K\text{.}\) Thus for \(n \geq M\text{,}\)

\begin{equation*} \abs{f(x_n) - 0} = f(x_n) \leq \nicefrac{1}{K} < \epsilon . \end{equation*}

Therefore, \(f\) is continuous at irrational \(c\text{.}\)

Let us end on an easier example.

Example 3.2.13.

Define \(g \colon \R \to \R\) by \(g(x) := 0\) if \(x \not= 0\) and \(g(0) := 1\text{.}\) Then \(g\) is not continuous at zero, but continuous everywhere else (why?). The point \(x=0\) is called a removable discontinuity. That is because if we would change the definition of \(g\text{,}\) by insisting that \(g(0)\) be \(0\text{,}\) we would obtain a continuous function. On the other hand, let \(f\) be the function of Example 3.2.10. Then \(f\) does not have a removable discontinuity at \(0\text{.}\) No matter how we would define \(f(0)\) the function would still fail to be continuous. The difference is that \(\lim_{x\to 0} g(x)\) exists while \(\lim_{x\to 0} f(x)\) does not.

We stay with this example to show another phenomenon. Let \(A := \{ 0 \}\text{,}\) then \(g|_A\) is continuous (why?), while \(g\) is not continuous on \(A\text{.}\) Similarly, if \(B := \R \setminus \{0 \}\text{,}\) then \(g|_B\) is also continuous, and \(g\) is in fact continuous on \(B\text{.}\)

Subsection 3.2.4 Exercises

Exercise 3.2.1.

Using the definition of continuity directly prove that \(f \colon \R \to \R\) defined by \(f(x) := x^2\) is continuous.

Exercise 3.2.2.

Using the definition of continuity directly prove that \(f \colon (0,\infty) \to \R\) defined by \(f(x) := \nicefrac{1}{x}\) is continuous.

Exercise 3.2.3.

Let \(f \colon \R \to \R\) be defined by

\begin{equation*} f(x) := \begin{cases} x & \text{if } x \text{ is rational,} \\ x^2 & \text{if } x \text{ is irrational.} \end{cases} \end{equation*}

Using the definition of continuity directly prove that \(f\) is continuous at \(1\) and discontinuous at \(2\text{.}\)

Exercise 3.2.4.

Let \(f \colon \R \to \R\) be defined by

\begin{equation*} f(x) := \begin{cases} \sin(\nicefrac{1}{x}) & \text{if } x \not= 0, \\ 0 & \text{if } x=0. \end{cases} \end{equation*}

Is \(f\) continuous? Prove your assertion.

Exercise 3.2.5.

Let \(f \colon \R \to \R\) be defined by

\begin{equation*} f(x) := \begin{cases} x \sin(\nicefrac{1}{x}) & \text{if } x \not= 0, \\ 0 & \text{if } x=0. \end{cases} \end{equation*}

Is \(f\) continuous? Prove your assertion.

Exercise 3.2.7.

Prove the following statement. Let \(S \subset \R\) and \(A \subset S\text{.}\) Let \(f \colon S \to \R\) be a continuous function. Then the restriction \(f|_A\) is continuous.

Exercise 3.2.8.

Suppose \(S \subset \R\text{,}\) such that \((c-\alpha,c+\alpha) \subset S\) for some \(c \in \R\) and \(\alpha > 0\text{.}\) Let \(f \colon S \to \R\) be a function and \(A:=(c-\alpha,c+\alpha)\text{.}\) Prove that if \(f|_A\) is continuous at \(c\text{,}\) then \(f\) is continuous at \(c\text{.}\)

Exercise 3.2.9.

Give an example of functions \(f \colon \R \to \R\) and \(g \colon \R \to \R\) such that the function \(h\) defined by \(h(x) := f(x) + g(x)\) is continuous, but \(f\) and \(g\) are not continuous. Can you find \(f\) and \(g\) that are nowhere continuous, but \(h\) is a continuous function?

Exercise 3.2.10.

Let \(f \colon \R \to \R\) and \(g \colon \R \to \R\) be continuous functions. Suppose that for all rational numbers \(r\text{,}\) \(f(r) = g(r)\text{.}\) Show that \(f(x) = g(x)\) for all \(x\text{.}\)

Exercise 3.2.11.

Let \(f \colon \R \to \R\) be continuous. Suppose \(f(c) > 0\text{.}\) Show that there exists an \(\alpha > 0\) such that for all \(x \in (c-\alpha,c+\alpha)\text{,}\) we have \(f(x) > 0\text{.}\)

Exercise 3.2.12.

Let \(f \colon \Z \to \R\) be a function. Show that \(f\) is continuous.

Exercise 3.2.13.

Let \(f \colon S \to \R\) be a function and \(c \in S\text{,}\) such that for every sequence \(\{ x_n \}\) in \(S\) with \(\lim\, x_n = c\text{,}\) the sequence \(\{ f(x_n) \}\) converges. Show that \(f\) is continuous at \(c\text{.}\)

Exercise 3.2.14.

Suppose \(f \colon [-1,0] \to \R\) and \(g \colon [0,1] \to \R\) are continuous and \(f(0) = g(0)\text{.}\) Define \(h \colon [-1,1] \to \R\) by \(h(x) := f(x)\) if \(x \leq 0\) and \(h(x) := g(x)\) if \(x > 0\text{.}\) Show that \(h\) is continuous.

Exercise 3.2.15.

Suppose \(g \colon \R \to \R\) is a continuous function such that \(g(0) = 0\text{,}\) and suppose \(f \colon \R \to \R\) is such that \(\abs{f(x)-f(y)} \leq g(x-y)\) for all \(x\) and \(y\text{.}\) Show that \(f\) is continuous.

Exercise 3.2.16.

(Challenging)   Suppose \(f \colon \R \to \R\) is continuous at \(0\) and such that \(f(x+y) = f(x) + f(y)\) for every \(x\) and \(y\text{.}\) Show that \(f(x) = ax\) for some \(a \in \R\text{.}\) Hint: Show that \(f(nx) = nf(x)\text{,}\) then show \(f\) is continuous on \(\R\text{.}\) Then show that \(\nicefrac{f(x)}{x} = f(1)\) for all rational \(x\text{.}\)

Exercise 3.2.17.

Suppose \(S \subset \R\) and let \(f \colon S \to \R\) and \(g \colon S \to \R\) be continuous functions. Define \(p \colon S \to \R\) by \(p(x) := \max \{ f(x) , g(x) \}\) and \(q \colon S \to \R\) by \(q(x) := \min \{ f(x) , g(x) \}\text{.}\) Prove that \(p\) and \(q\) are continuous.

Exercise 3.2.18.

Suppose \(f \colon [-1,1] \to \R\) is a function continuous at all \(x \in [-1,1] \setminus \{ 0 \}\text{.}\) Show that for every \(\epsilon\) such that \(0 < \epsilon < 1\text{,}\) there exists a function \(g \colon [-1,1] \to \R\) continuous on all of \([-1,1]\text{,}\) such that \(f(x) = g(x)\) for all \(x \in [-1,-\epsilon] \cup [\epsilon,1]\text{,}\) and \(\abs{g(x)} \leq \abs{f(x)}\) for all \(x \in [-1,1]\text{.}\)

Exercise 3.2.19.

(Challenging)   A function \(f \colon I \to \R\) is convex if whenever \(a \leq x \leq b\) for \(a,x,b\) in \(I\text{,}\) we have \(f(x) \leq f(a) \frac{b-x}{b-a} + f(b) \frac{x-a}{b-a}\text{.}\) In other words, if the line drawn between \(\bigl(a,f(a)\bigr)\) and \(\bigl(b,f(b)\bigr)\) is above the graph of \(f\text{.}\)

  1. Prove that if \(I = (\alpha,\beta)\) an open interval and \(f \colon I \to \R\) is convex, then \(f\) is continuous.

  2. Find an example of a convex \(f \colon [0,1] \to \R\) which is not continuous.

Named after the German mathematician Johann Peter Gustav Lejeune Dirichlet 2  (1805–1859).
https://en.wikipedia.org/wiki/Peter_Gustav_Lejeune_Dirichlet
Named after the German mathematician Carl Johannes Thomae 4  (1840–1921).
https://en.wikipedia.org/wiki/Carl_Johannes_Thomae
For a higher quality printout use the PDF versions: https://www.jirka.org/ra/realanal.pdf or https://www.jirka.org/ra/realanal2.pdf