If $f$ is continuous on a closed set in $R^1$, then is $g$ also continuous on that closed set given that $f(x)= g(x)$ for all points on that set

general-topologyproof-explanationproof-writingreal-analysis

(Baby Rudin Chapter 4 Exercise 5)

If $f$ is continuous on a closed set in $R^1$, prove there exist continuous functions $g$ on $R^1$ such that $g(x)=f(x)$ for all $x \in \mathbb{E}$.

My attempt:

Suppose $f$ is a real, continuous function defined on the closed set $E \subset \mathbb{R}^1$. Then, $E^c$ is open in $\mathbb{R}^1$. By Exercise 29 in Chapter 2, $E^c$ is union of an at most countable collection of disjoint open intervals. Thus, we can write
\begin{equation*}
E^c = \bigcup_{i = 1}^{n} (a_i, b_i)
\end{equation*}

where $n \in \mathbb{N}$ and $a_i < b_i < a_{1+i} < b_{1+i}$. Note that it is possible (although not necessary) that segments of the form $(-\infty, a_0)$ and $(b_0, +\infty)$ also constitute part of $E^c$; if one or both of these semi-infinite intervals constitute $E^c$, we can write
\begin{equation}\label{5a}
E^c = \bigcup_{i = 1}^{n} (a_i, b_i) \cup (-\infty, a_0) \cup (b_0, +\infty)
\end{equation}

and, of course, adjust the equation accordingly if either $(-\infty, a_0)$ or $(b_0, +\infty)$ does not constitute $E^c$.
Now, define $g$ as:
[$g(x) =$
\begin{cases}
f(x) & \text{if $x \in E$} \\
f(a_i)+(x-a_i)\frac{f(b_i)-f(a_i)}{b_i-a_i} & \text{if $x \in (a_i, b_i)$} \\
f(b_0) & \text{if $x \in (b_0, +\infty)$} \\
f(a_0) & \text{if $x \in (-\infty, a_0)$}
\end{cases}
]
Clearly, $g$ is an extension of $f$ on $\mathbb{R}^1$ and it remains to show that $g$ is continuous on $\mathbb{R}^1$. [Then I show that $g$ is continuous on all points of $E^c$]

My question: Do I need to show that $g$ is continuous on $E$ or since $f(x) = g(x) \forall x \in E$, it is immediate that since $f$ is continuous on $E$ that $g$ is also continuous on all points of $E$? Can someone please explain this part of this question?

Best Answer

Then, $E^c$ is open in $\mathbb{R}^1$. By Exercise 29 in Chapter 2, $E^c$ is union of an at most countable collection of disjoint open intervals. Thus, we can write $$E^c = \bigcup_{i = 1}^{n} (a_i, b_i)$$

I'm not sure why you wrote the union as finite, when you just wrote yourself that it is countable. In fact the general form is:

$$E^c = \bigcup_{i = 1}^{\infty} (a_i, b_i)$$

with $a_i,b_i=\pm\infty$ a possibility. Note that the ordering you've enforced isn't really relevant. The only important thing is that these intervals are pairwise disjoint.

My question: Do I need to show that $g$ is continuous on $E$ or since $f(x) = g(x) \forall x \in E$, it is immediate that since $f$ is continuous on $E$ that $g$ is also continuous on all points of $E$? Can someone please explain this part of this question?

This argument is not enough. Consider

$$f,g:\mathbb{R}\to\mathbb{R}$$ $$f(x)=0$$ $$g(x)=\begin{cases} 0 &\text{if }x\in[0,1] \\ 1 &\text{otherwise} \end{cases}$$

and note that for $E=[0,1]$ both functions satisfy your assumptions, but $g$ is not continuous at $E$. It fails to be continuous at the boundary $\{0,1\}$. That's because continuity on $E$ also depends on values outside of $E$. Unless $E$ is open (but here we don't have such assumption).

Your $g$ is a glueing of multiple (potentially infinitely many) functions. And glueing is continuous by (the infinite variant of) the pasting lemma. In order to apply the pasting lemma here all pieces have to be defined over closed subsets or alternatively all over open. But you cannot mix them like you did. We will use closed subsets${}^1$. In other words, for that

$$ \begin{cases} f(x) & \text{if $x \in E$} \\ f(a_i)+(x-a_i)\frac{f(b_i)-f(a_i)}{b_i-a_i} & \text{if $x \in (a_i, b_i)$} \\ f(b_0) & \text{if $x \in (b_0, +\infty)$} \\ f(a_0) & \text{if $x \in (-\infty, a_0)$} \end{cases}$$

to be continuous you need to know that each piece can be extended to its own closure. Meaning you need to show that $f(a_i)+(x-a_i)\frac{f(b_i)-f(a_i)}{b_i-a_i}$ defined on $(a_i, b_i)$ actually can be extended to $[a_i, b_i]$. So first you need to show that both limits exist, which is trivial. The same for the constant pieces. Thus this is what we should have:

$$ \begin{cases} f(x) & \text{if $x \in E$} \\ f(a_i)+(x-a_i)\frac{f(b_i)-f(a_i)}{b_i-a_i} & \text{if $x \in [a_i, b_i]$} \\ f(b_0) & \text{if $x \in [b_0, +\infty)$} \\ f(a_0) & \text{if $x \in (-\infty, a_0]$} \end{cases}$$

Now each piece is defined over a closed subset. Next you have to show that values agree wherever those pieces overlap, i.e. we have two definitions for $x=a_i$ and $x=b_i$, they have to agree. But that's not hard at all and thus the pasting lemma applies. Therefore the construction seems to be fine and continuous.

Note that what you are trying to prove is the special case of the Tietze extension theorem.

${}^1$ For the infinite variant of the pasting lemma, closed subsets have to form a locally finite collection, meaning every point belongs to at most finitely many closed subsets from the collection. But our collection does satisfy this. Since $(a_i,b_i)$ are pairwise disjoint then every point belongs to at most three elements from $\{E, [a_1,b_1], [a_2,b_2], [a_3,b_3],\ldots\}$.

Related Question