# Prove continuity of piecewise function using epsilon-delta

Suppose we have a function $\phi$ so that

$$\phi (x)=\cases{f(x) & \text{ if } x\le 0\\ g(x)& \text{ if } x>0.}$$ where $f$ is continuous on $(-\infty,0]$ and $g$ is continuous on $(0,\infty)$, and suppose $f(0)=g(0)$ (that is, the value of $g(0)$ if $g$ were extended to a continuous function on $[0,\infty)$, which it can be by some theorem). For example, we could have:

$$\phi (x)=\cases{x & \text{ if } x\le 0\\ x^2& \text{ if } x>0.}$$

How can we rigorously show that $\phi$ is continuous at $0$, using either the $\epsilon, \delta$ definition OR the equivalent definition that $\phi$ is continuous at $x_0$ iff for every $(x_n)$ with $x_n \to x_0$ we have $\phi(x_n)\to \phi(x_0)$?

I have seen this proof by looking at the both the left and right side continuity (such as here), but I'm not sure how that's rigorous only assuming the above two ways to prove continuity (since we have to consider every $(x_n)$, not just $(x_n)$ approaching from the left or the right). I suppose a proof of this left-right continuity would also suffice, but a proof using either of the two above methods in a nice way would be slicker I think, if possible.

Is the way to go about it by actually extending $g$ to the extra point at $0$ and noting that $g(0)=f(0)$? If so, how can that be made rigorously precise?

• the only problem where $\phi(x)$ can be discontinuous is at $0$, and there, the right and left limits exist, and both are equal to $\phi(0)$. with the $\epsilon, \delta$ it will be exactly the same, since when $x_0 > 0$ we look only to $g(x)$, and when $x_0 < 0$ only to $f(x)$, while at $x_0=0$ you'll write the limits I mentioned explicitly in term of $\epsilon, \delta$ – reuns May 20 '16 at 4:18
• and the definition of the continuity at $x_0$ needs 3 steps : $\lim_{x \to x_0^+} \phi(x)$ exists, $\lim_{x \to x_0^-} \phi(x)$ exists, and both are equal to $\phi(x_0)$. (consider the function $\sin(1/x)$ to see an example of function where the right and left limits don't even exist) – reuns May 20 '16 at 4:23

By continuity of $f$ and $g$,
$\forall \epsilon>0, \exists \delta_{f,\epsilon} >0, |x| \leq \delta \implies |f(x)-f(0)| \leq \epsilon$
$\forall \epsilon>0, \exists \delta_{g,\epsilon} >0, |x| \leq \delta \implies |g(x)-g(0)| \leq \epsilon$
Hence Let $\delta_{\epsilon}=\min(\delta_{f,\epsilon},\delta_{g,\epsilon})$,
$\forall \epsilon>0, |x|\leq \delta_{\epsilon} \implies |\phi(x)-\phi(0)|\leq \epsilon$