# Real Analysis: Continuity

## Continuity

### Motivation

Consider the function $f : \mathbb{R} \rightarrow \mathbb{R}$ where $f(x) = x^2.$ If we look at the graph of the function, we notice that it is all of one piece. In particular, if we want to draw it, we can place out chalk down at one end and draw the whole function (or at least the little part we're looking) without lifting it up until the end. This is possible because $f$ does not have any holes or sudden jumps in it. In contrast, the function $g : \mathbb{R} \rightarrow \mathbb{R}$ where $g(x) = x^2$ when $x < 1$  and $g(x) = x^2 + 1$ when $x \geq 1.$ If we wanted to draw $g$ on the blackboard, we wouldd have have to pick up our chalk once we got to $1$ along the $x$-axis and jump from $1$ to $2$ on the $y$-axis to continue drawing.

The notion of a function's image being all of one piece like this is called continuity, which we now define rigorously.

### Continuity - General Definition

A function $f$ from a metric space $(X, d_X)$ to a metric space $(Y, d_Y)$ is continuous at a point $c \in X$ if for every open set $S$ containing $f(c),$ there exists an open set $T$ containing $c$ such that $f(T) \subseteq S.$ A function is continuous if it is continuous at every point in its domain. A function may also be called locally continuous at $c$ and globally continuous to resolve any potential ambiguity.

### Continuity - Metric Definition

The above definition is the most general definition of continuity, and it applies to all topological spaces, not just metric spaces. However, this generality comes at the cost of applicability. Thankfully, the general definition implies a more applicable definition for metric spaces.

A function $f$ from a metric space $(X, d_X)$ to a metric space $(Y, d_Y)$ is continuous at a point $c \in X$ if for every $\varepsilon > 0$ there exists a $\delta > 0$ such that $d_Y(f(x), f(c)) < \varepsilon$ for all points $x \in X$ where $d_X(x, c) < \delta.$ In other words, $f$ is continuous at $c$ if its values become closer to $f(c)$ as its inputs get closer to $c.$ A function itself is continuous if it is continuous at all points in its domain.

### Discontinuity

If $f$ is not continuous at $c,$ then $f$ is discontinuous at $c,$ and $c$ is a discontinuous point or discontinuity of $f.$ This implies that $f$ is discontinuous for all values where it is not defined, as continuity is only a property of points in $f$'s domain. If $f$ is not continuous at any point in its domain, then $f$ is nowhere continuous.

### Algebraic Continuity Theorem

The algebraic continuity theorem states that if $f$ and $g$ are real functions that are both continuous at a point $c,$ then their algebraic combinations are also continuous at $c$:

• $f + g$ is continuous at $c.$

• $f - g$ is continuous at $c.$

• $f \cdot g$ is continuous at $c.$

• $1 / f$ is continuous at $c$ if $f(c) \neq 0.$

• Corollary: $f / g$ is continuous at $c$ if $g(c) \neq 0.$

The above holds for any point $c,$ the sum, difference, and product of continuous functions is globally continuous over the domain of the resulting function. The quotient of $1 / f$ is likewise globally continuous, as zeros of $f$ are not elements of the domain of $1 / f.$

The algebraic continuity theorem is very powerful because it lets us prove that entire classes of functions are continuous. Namely, it lets us prove that the monomials, polynomials, and rational functions are all continuous. Furthermore, when we construct the exponential, logarithmic, and trigonometric functions and prove that they are continuous, we'll be able to know that functions like $f(x) = e^x + x^2$ are also continuous.

### Composition Continuity Theorem

Another important theorem regarding continuous functions is that the composition of continuous functions is continuous. Specifically, it states that if $g : (X, d_X) \rightarrow (Y, d_Y)$ is continuous at a point $c \in X$ and $f : (Y, d_Y) \rightarrow (Z, d_Z)$ is continuous as $g(c) \in Y,$ then $f \circ g$ is continuous at $p$. The composition continuity theorem lets us combine continuous functions in ways that the algebraic continuity theorem does not. For example, given that $f(x) = |x|$ and $g(x) = x^3$ are continuous, we can use the composition continuity theorem to conclude that $f(g(x)) = |x^3|$ is also continuous.

## Problems

1. Let $f$ be a function from the metric space $(X, d_X)$ to the metric space $(Y, d_Y).$ Can $f$ be continuous at a point $p$ if either $d_X$ or $d_Y$ is the discrete metric? If so, is $f$ always continuous at $p\text{?}$ If not, give an example.

If $d_X$ is discrete, then every function $f$ is continuous every point in its domain. Take $\delta = \frac{1}{2},$ and it follows that the only value $x \in X$ for which $d(x, p) < \delta$ is $p$ itself. This means that $d_Y(f(x), f(p)) = d_Y(f(p), f(p)) = 0 < \varepsilon$ for all positive $\varepsilon.$

If $d_Y$ is discrete, then $f$ can be continuous at $p,$ as is the case when $d_X$ is also the discrete metric. However, functions that are continuous at $p$ under other metrics on $Y$ may not necessarily be continuous under the discrete metric. For example, the function $f : \mathbb{R} \rightarrow \mathbb{R}$ where $f(x) = x$ is continuous at every point $x \in \mathbb{R}$ under the standard metric on the domain and codomain. However, when the discrete metric is used for the codomain, $d(f(x), f(p)) < 1$ only when $x = p,$ and thus there is no $\delta > 0$ such that $d_Y(f(x), f(p)) < 1$ whenever $d_X(x, p) < \delta.$

2. Let $f$ be a function from $(X, d_X)$ to $(Y, d_Y).$ Show that $f$ is continuous at every isolated point of $X.$

Let $c$ be an isolated point of $X.$ Then there exists an $r > 0$ such that $N_{r}(x)$ contains no other points of $X$ besides $c.$ Pick $\varepsilon > 0,$ and pick $\delta = \frac{1}{2}r.$ Assume that $d_X(x, c) < \frac{1}{2}r.$ It follows that the only point $x$ for which this holds is $c$ itself, in which case $d_X(x, c) = d_X(c, c) = 0.$ In turn, $d_Y(f(x), f(c)) = d_Y(f(c), f(c)) = 0 < \varepsilon.$ Therefore $f$ is continuous at $c.$

3. Algebraic Continuity Theorem I: Let $f$ and $g$ be continuous real functions. Show that $f + g$ is continuous

Given an $\varepsilon > 0,$ we would like to find a $\delta > 0$ such that $d(f(x) + g(x), f(c) + g(c)) < \varepsilon$ whenever $d(x, c) < \delta.$ First, expand and reorganize the metric definition:

$d(f(x) + g(x), f(c) + g(c)) = |(f(x) + g(x)) - (f(c) + g(c))| \\ d(f(x) + g(x), f(c) + g(c)) = |(f(x) - f(c)) - (g(c) - g(x))|$

Next, apply the triangle inequality and apply the properties of absolute value:

$d(f(x) + g(x), f(c) + g(c)) \leq |f(x) - f(c)| + |g(c) - g(x)| \\ d(f(x) + g(x), f(c) + g(c)) \leq |f(x) - f(c)| + |g(x) - g(c)|$

Because $f$ is continuous, for every $\varepsilon_f > 0,$ there exists a $\delta_f > 0$ such that $d(f(x), f(c)) = |f(x) - f(c)| < \varepsilon_f$ whenever $d(x, c) = |x - c| < \delta_f.$ Likewise, because $g$ is continuous, for every $\varepsilon_g > 0,$ there exists a $\delta_g > 0$ such that $d(g(x), g(c)) = |g(x) - g(c)| < \varepsilon_g$ whenever $d(x, c) = |x - c| < \delta_g.$ Pick $\varepsilon_f = \frac{1}{2}\varepsilon$ and $\varepsilon_g = \frac{1}{2}\varepsilon,$ and set $\delta = \text{min}(\{\delta_f, \delta_g\})$ to make the final substitution:

$d(f(x) + g(x), f(c) + g(c)) < \dfrac{1}{2}\varepsilon + \dfrac{1}{2}\varepsilon \\ d(f(x) + g(x), f(c) + g(c)) < \varepsilon$

Therefore $f + g$ is continuous.

4. Algebraic Continuity Theorem II: Show that if $f$ and $g$ are continuous real functions, then $f - g$ is continuous.

This proof is nearly identical to the previous one.

Given some $\varepsilon > 0,$ we would like to find a $\delta > 0$ such that $d(f(x) - g(x), f(c) - g(c)) < \varepsilon$ whenever $d(x, c) < \delta.$ First, expand and reorganize the metric definition:

$d(f(x) - g(x), f(c) - g(c)) = |(f(x) - g(x)) - (f(c) - g(c))| \\ d(f(x) - g(x), f(c) - g(c)) = |(f(x) - f(c)) - (g(x) - g(c))|$

Next, apply the triangle inequality:

$d(f(x) - g(x), f(c) - g(c)) \leq |f(x) - f(c)| + |g(x) - g(c)|$

Since $f$ is continuous, given $\varepsilon_f = \frac{1}{2}\varepsilon,$ there exists a $\delta_f > 0$ such that $d(f(x), f(c)) = |f(x) - f(c)| < \varepsilon_f$ whenever $d(x, c) = |x - c| < \delta_f.$ Likewise, since $g$ is continuous, given $\varepsilon_g = \frac{1}{2}\varepsilon,$ there exists a $\delta_g > 0$ such that $d(g(x), g(c)) = |g(x) - g(c)| < \varepsilon_g$ whenever $d(x, c) = |x - c| < \delta_g.$ Pick $\delta_g = \text{min}(\{\delta_f, \delta_g\})$ and make the following substitution:

$d(f(x) - g(x), f(c) - g(c)) < \dfrac{1}{2}\varepsilon + \dfrac{1}{2}\varepsilon \\ d(f(x) - g(x), f(c) - g(c)) < \varepsilon$

Therefore $f - g$ is continuous.

5. Algebraic Continuity Theorem III: Show that if $f$ and $g$ are continuous real functions, then $fg$ is continuous.

We would like to find a $\delta > 0$ for all $\varepsilon > 0$ such that $d(f(x)g(x), f(c)g(c)) < \varepsilon$ whenever $d(x, c) < \delta.$ First, expand the metric function:

$d(f(x)g(x), f(c)g(c)) = |f(x)g(x) - f(c)g(c)|$

Unlike the previous proofs, we are not immediately presented with an algebraic expression that can be neatly decomposed into the $|f(x) - f(c)|$ and $|g(x) - g(c)|$ terms available to us given the continuity of $f$ and $g,$ respectively. However, by adding the terms $0 = f(x)g(c) - f(x)g(c)$ to the inside of the absolute value expression, we can get much closer:

$d(f(x)g(x), f(c)g(c)) = |f(x)g(x) + f(x)g(c) - f(x)g(c) - f(c)g(c)| \\ d(f(x)g(x), f(c)g(c)) = |f(x)(g(x)-g(c)) - g(c)(f(x)-f(c))| \\ d(f(x)g(x), f(c)g(c)) = |f(x)(g(x)-g(c)) + g(c)(f(c)-f(x))| \\ d(f(x)g(x), f(c)g(c)) \leq |f(x)(g(x)-g(c))| + |g(c)(f(c)-f(x))| \\ d(f(x)g(x), f(c)g(c)) \leq |f(x)||g(x)-g(c)| + |g(c)||f(c)-f(x)| \\ d(f(x)g(x), f(c)g(c)) \leq |f(x)||g(x)-g(c)| + |g(c)||f(x)-f(c)|$

Since there are now two terms, each involving the absolute value terms used in the continuity definition, we would like to make a substitution for each term involving $\frac{1}{2}\varepsilon$ such that the two ultimately sum to $\varepsilon.$ Thus, because $f$ is continuous, given $\varepsilon_f = \dfrac{\varepsilon}{2|g(c)|},$ there is a $\delta_f > 0$ such that $|f(x) - f(c)| < \varepsilon_f$ whenever $|x - c| < \delta_f.$ Substitute this back into the equation to make some progress:

$d(f(x)g(x), f(c)g(c)) < |f(x)||g(x)-g(c)| + |g(c)|\left(\dfrac{\varepsilon}{2|g(c)|}\right) \\ d(f(x)g(x), f(c)g(c)) < |f(x)||g(x)-g(c)| + \dfrac{\varepsilon}{2}$

Now, it would be nice if we could make the same substitution for the other term, but unlike the freshly departed $|g(c)|$ term, the $|f(x)|$ term is not a constant. However, we can turn to the fact that given another $\varepsilon_f' > 0,$ there exists a $\delta_f' > 0$ such that $|f(x) - f(c)| < \varepsilon_f'$ whenever $|x - c| < \delta_f'$ for some help. By applying the triangle inequality, we see that $|f(x) - f(c)| \leq |f(x)| + |f(c)|,$ and thus $|f(x)| < \varepsilon_f' + |f(c)|.$ If we take $\delta = \text{min}(\{\delta_f, \delta_f'\}),$ and consider when $|x - c| < \delta,$ we can substitute this term in to make some additional progress:

$d(f(x)g(x), f(c)g(c)) < (\varepsilon_f' + |f(c)|)|g(x)-g(c)| + \dfrac{\varepsilon}{2}$

Finally, because $g$ is continuous, given $\varepsilon_g = \frac{\varepsilon}{2(\varepsilon_f' + |f(c)|)},$ there is a $\delta_g > 0$ such that $|g(x) - g(c)| < \varepsilon_g$ whenever $|x - c| < \delta_g.$ Picking $\delta = \text{min}(\{\delta_f, \delta_f', \delta_g\})$ and requiring again that $|x - c| < \delta,$ we can make a final substitution:

$d(f(x)g(x), f(c)g(c)) < (\varepsilon_f' + |f(c)|)\left(\dfrac{\varepsilon}{2(\varepsilon_f' + |f(c)|)}\right) + \dfrac{\varepsilon}{2} \\ d(f(x)g(x), f(c)g(c)) < \dfrac{\varepsilon}{2} + \dfrac{\varepsilon}{2} \\ d(f(x)g(x), f(c)g(c)) < \varepsilon$

Therefore $fg$ is continuous.

6. Algebraic Continuity Theorem IV: Show that if a real function $f$ is continuous at a point $c,$ and $a \neq 0,$ then $g(x) = \dfrac{1}{f(x)}$ is also continuous at $c.$

For every $\varepsilon > 0,$ we would like to find a $\delta > 0$ such that $d(g(x), g(c)) = |g(x) - g(c)| < \varepsilon$ whenever $|x - c| < \delta.$ Expanding the definition of $g$ in the metric give us

$d(g(x), g(c)) = \left| \dfrac{1}{f(x)} - \dfrac{1}{f(c)} \right|$

Multiplying each term by $1$ produces a common denominator:

$d(g(x), g(c)) = \left| \dfrac{f(c)}{f(x)f(c)} - \dfrac{f(x)}{f(x)f(c)} \right| \\ d(g(x), g(c)) = \left| \dfrac{f(c) - f(x)}{f(x)f(c)} \right| \\ d(g(x), g(c)) = \left| \dfrac{f(x) - f(c)}{f(x)f(c)} \right| \\ d(g(x), g(c)) = \dfrac{|f(x) - f(c)|}{|f(x)f(c)|} \\ d(g(x), g(c)) = \dfrac{|f(x) - f(c)|}{|f(x)||f(c)|}$

Because $f$ is continuous at $c,$ for every $\varepsilon_f > 0,$ there is a $\delta_f > 0$ such that $d(f(x), f(c)) = |f(x) - f(c)| < \varepsilon_f$ whenever $d(x, c) = |x - c| < \delta_f.$ Pick $\varepsilon_f = \frac{1}{2}|f(c)|$ such that $|f(x) - f(c)| < \frac{1}{2}|f(c)|.$ It follows that $|f(x)| > \frac{1}{2}|f(c)|.$ Substitute this back in to produce an inequality:

$d(g(x), g(c)) < \dfrac{|f(x) - f(c)|}{\left(\frac{1}{2}|f(c)|\right)|f(c)|^2} \\ d(g(x), g(c)) < \dfrac{2|f(x) - f(c)|}{|f(c)|^2}$

Now pick $\frac{1}{2}|f(c)|^2\varepsilon > 0.$ By the continuity of $f$, there exists a $\delta_f' > 0$ such that $|f(x) - f(c)| < \frac{1}{2}|f(c)|^2\varepsilon$ whenever $|x - c| < \delta_f'.$ Pick $\delta = \text{min}(\{\delta_f, \delta_f'\})$ to make the final substitution for when $|x - c| < \delta$:

$d(g(x), g(c)) < \dfrac{2|f(c)|^2\varepsilon}{2|f(c)|^2} \\ d(g(x), g(c)) < \varepsilon$

Therefore $g$ is continuous at $c.$

7. Let $f$ be a function from one metric space $(X, d_X)$ to another $(Y, d_Y).$ Show that the constant function $f(x) = c$ is continuous.

Pick some $p \in X$ and $\varepsilon > 0.$ We would like to find a $\delta$ such that $d_Y(f(x), f(p)) < \varepsilon$ whenever $d_X(x, p) < \delta.$ Pick any $\delta > 0,$ perhaps $\delta = 1.$ Then whenever $d_X(x, p) < \delta,$ it follows from the fact that $f$ is the constant function that $d_Y(f(x), f(p)) = d_Y(c, c) = 0 < \varepsilon.$ Therefore $f$ is continuous at $p.$ Since this was true for all $p \in X,$ it follows that $f$ is continuous.

8. Show that the identity function $f(x) = x$ is continuous.

Pick $x \in \text{Dom}(f)$ and let $\varepsilon > 0.$ Pick $\delta = \varepsilon.$ Then whenever $d(x, c) < \delta,$ it follows that $d(f(x), f(c)) = d(x, c) < \delta = \varepsilon.$ Therefore $f$ is continous.

9. Show that monomials are continuous.

Proof by induction. Base case: The constant function $p(x) = cx^0 = c$ is continuous for any $c \in \mathbb{R}.$ Inductive step: Assume monomials of the form $m(x) = cx^n$ are continuous for some $n \in \mathbb{N}$. Note that $q(x) = cx^{n+1} = cx^n \cdot x$ is the product of two continuous functions, $cx^n$ and $x.$ By the algebraic continuity theorem, it follows that $q(x)$ is also continuous. The result follows by induction.

10. Show that polynomials are continuous.

Proof by induction. Base case: Let $p \in \mathcal{P}_0(\mathbb{R})$ such that $p(x) = c$ for some constant $c \in \mathbb{R}.$ Since $p$ is a constant function, it is continuous. Inductive step: Assume polynomials in the set $\mathcal{P}_n(\mathbb{R})$ are continuous. Let $p \in \mathcal{P}_{n+1}(\mathbb{R}).$ Then $p(x) = \sum\limits_{i=0}^{n+1} m_i(x),$ where $m_i \in \mathcal{M}_i(\mathbb{R}).$ Expanding the sum shows that $p(x) = \left(\sum\limits_{i=0}^{n} m_i(x)\right) + m_{n+1}(x).$ The first term is in $\mathcal{P}_{n}(\mathbb{R})$ and therefore continuous, and the second term is a monomial and therefore continuous. Since $p$ is the sum of two continuous functions, by the algebraic continuity theorem, $p$ is also continuous. The result follows by induction.

11. Show that rational functions are continuous.

Consider a rational function $f(x) = \frac{p(x)}{q(x)},$ where $p, q \in \mathcal{P}(\mathbb{R}).$ Because $p$ and $q$ are polynomials, they are continuous. It follows by the algebraic continuity theorem that $f$ is also continuous..

But what about the locations where $q(x) = 0$?

Remember that a function is continuous if it is continuous at every point in its domain. Any points excluded from the domain of a rational function due to zeros of the denominator do not preclude continuity of the whole function.

12. Show that the absolute value function is continuous.

We must show that $f$ is continuous at every point in its domain. Thus for every $c \in \mathbb{R},$ for every $\varepsilon > 0,$ we must find a $\delta > 0$ such that $d(|x|, |c|) = ||x| - |c|| < \varepsilon$ whenever $d(x, c) = |x - c| < \delta.$

Pick $c \in \mathbb{R},$ select some $\varepsilon > 0.$ Assume $|x - c| < \delta$ and set $\delta = \varepsilon.$ Note that $||x| - |c|| \leq |x - c|.$ Since $|x - c| < \varepsilon,$ it follows by transitivity that $||x| - |c|| < \varepsilon.$ Therefore the absolute value function is continuous.

13. Composition Continuity Theorem: Show that if $f$ is a continuous function from $(Y, d_Y)$ to $(Z, d_Z)$ and $g$ is a continuous function from $(X, d_X)$ to $(Y, d_Y)$, then $f \circ g$ is continuous.

To show that $f \circ g$ is continuous, we must show that for every $\varepsilon > 0,$ there exists a $\delta > 0$ such that $d_Z((f \circ g)(x), (f \circ g)(c)) = d(f(g(x)), f(g(c))) < \varepsilon$ whenever $d_X(x, c) < \delta.$

Because $f$ is continuous, for every $\varepsilon > 0,$ there exists a $\delta_f$ such that $d_Z(f(p), f(q)) < \varepsilon$ whenever $d_Y(p, q) < \delta_f.$ Likewise, because $g$ is continuous, for every $\varepsilon_g > 0,$ there exista a $\delta$ such that $d_Y(g(x), g(c)) < \varepsilon_f$ whenever $d(x, c) < \delta.$ Set $p = g(x)$ and $q = g(c)$ and pick $\varepsilon_g = \delta_f.$ Then $d_Z(f(g(x)), f(g(c))) < \varepsilon$ whenever $d_X(x, c) < \delta.$ Therefore $f \circ g$ is continuous.

14. Consider the following real function:

$f(x) = \left\{\begin{array}{ll} 0 & x \in \mathbb{Q}\\x & x \in \mathbb{R} - \mathbb{Q} \end{array}\right.$

Show that $f$ is nowhere continuous.

Proof by contradiction. Assume $f$ is continuous at some point $c \in \mathbb{R}.$ Then for every $\varepsilon > 0$ there exists a $\delta > 0$ such that $d(f(x), f(c)) = |f(x) - f(c)| < \varepsilon$ whenever $d(x, c) = |x - c| < \delta.$ Pick $\varepsilon = \frac{1}{2}$ and consider the point $k = c + \frac{1}{2}\delta,$ which has the property that $|k - c| < \delta.$ Between $c$ and $k$ there are a rational number, call it $p$, and an irrational number, call it $q$. It follows that $|p - c| < \delta$ and $|q - c| < \delta.$ If $c$ is rational, then $|f(q) - f(c)| = 1 > \frac{1}{2},$ and if instead $c$ is irrational, then $|f(p) - f(c)| = 1 > \frac{1}{2}.$ Thus $f$ could not have been continuous at $c$ after all. Since this was true for an arbitrary point in $f$'s domain, it follows that $f$ is nowhere continuous.

15. Consider the function $f : (X, d_X) \rightarrow (Y, d_Y).$ Show that if $f$ is continuous at a point $c \in Z \subseteq X$ then the restriction $f|Z$ is also continuous at $c.$

Since $f$ is continuous at $c,$ for every $\varepsilon > 0$ there exists a $\delta > 0$ such that $d_Y(f(x), f(c)) < \varepsilon$ whenever $d_X(x, c) < \delta.$ It follows by definition of restriction that $f|Z(x) = f(x)$ for all $x \in Z.$ Therefore $d_Y(f|Z(x), f|Z(c)) = d_Y(f(x), f(c)) < \varepsilon$ whenever $d_X(x, c) < \delta.$ Therefore $f|Z$ is continuous at $c.$