(Baby Rudin Chapter 4 Exercise 5)
I want to follow up on my previous question. (Previously, I asked if I needed to even prove that $g$ is continuous on the endpoints of $E$. Here, I want to ask about the actual methodology of proving that $g$ is continuous on the endpoints.)
Suppose $f$ is a real, continuous function defined on the closed set $E \subset \mathbb{R}^1$. Prove that there exists real, continuous function $g$ on $\mathbb{R}^1$ such that $g(x) = f(x) \forall x \in E$.
My attempt:
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$]
- Then, to show that $g$ is continuous when $x \in E$, it is clear from the definiton of $g$ that $g$ is continuous if $x$ is an interior point of $E$ and it remains to show that $g$ is continuous if $x=a_i$ or $x=b_i$ for some $i$ (endpoints of $E$)
Now, it suffices prove that $g$ is continuous if $x=a_i$ (the $x=b_i$ case is probably identical). My attempt to prove that $g$ is continuous if $x=a_i$ so far:
If $x=a_i$ for some $i$, since $g$ is linear in $(a_i, b_i)$ by construction and $a_i \in E$, we have \begin{equation*} g(a_i+) = \lim\limits_{u \to a_i+}g(u) = f(a_i) = g(a_i) \end{equation*}
This is where I got stuck. Of course, I want to prove that $$g(a_i-)=g(a_i)$$ but I don't know how this can be proven. Unfortunately, I can't adopt the same methodology as I did in showing that $ g(a_i+) =g(a_i)$. How can I complete this proof?
Fix $\epsilon>0$. Since $f$ is continuous, there is a $\delta>0$ such that $|f(x)-f(a_i)|<\epsilon$ for all $x\in E\cap(a_i-\delta,a_i]$. If $E\cap(a_i-\delta,a_i)=\varnothing$, then $a_i=b_j$ for some $j$, and proving continuity of $g$ from the left at $b_j$ is like proving continuity from the right at $a_i$, which you know how to do. Otherwise, fix $x_0\in E\cap(a_i-\delta,a_i)$; I claim that $|g(x)-g(a_i)|<\epsilon$ for all $x\in(x_0,a_i]$.
This is immediate for $x\in E\cap(x_0,a_i]$. If $x\notin E$, then $x\in(a_j,b_j)\subseteq(x_0,a_i)$ for some $j$, and by construction $g(x)$ lies between $f(a_j)$ and $f(b_j)$. Thus,
$$|g(x)-g(a_i)|<\max\{|f(a_j)-f(a_i)|,|f(b_j)-f(a_i)|\}<\epsilon\;,$$
as claimed.