Q:

Proof continuity for piecewise functions

Consider the following function: $f(n) = \begin{cases} f_1(n) & n \leq a \\
f_2(n) & n > a \end{cases}$, where $f_1$ and $f_2$ are continuous. I've read that a function like that is continuous if and only if $f_1(a) = f_2(a)$. This seems to be logical, but how do you proof that?

A:

If $f$ is continuous, then $\lim_{x\rightarrow a^{-}}f(x)=f(a)$, but $f(x)=f_{1}(x)$ for $x<a$, so $\lim_{x\rightarrow a^{-}}f_{1}(x)=f(a)$. Since $f_{1}$ is continuous, then $\lim_{x\rightarrow a^{-}}f_{1}(x)=f_{1}(a)$, so $f_{1}(a)=f(a)$. Similarly, $f_{2}(a)=f(a)$, so $f_{1}(a)=f_{2}(a)$.
If $f_{1}(a)=f_{2}(a)$, then $\lim_{x\rightarrow a^{-}}f(x)=\lim_{x\rightarrow a^{-}}f_{1}(x)=f_{1}(a)$, also $\lim_{x\rightarrow a^{+}}f(x)=\lim_{x\rightarrow a^{+}}f_{2}(x)=f_{2}(a)$, but $f_{1}(a)=f_{2}(a)$, so $\lim_{x\rightarrow a^{-}}f(x)=\lim_{x\rightarrow a^{+}}f(x)$, hence $\lim_{x\rightarrow a}f(x)$ exists and equals to either $f_{1}(a)$ or $f_{2}(a)$. But now $f(a)=f_{1}(a)$, so $\lim_{x\rightarrow a}f(x)=f_{1}(a)=f(a)$, so $f$ is continuous at $x=a$.

