This is a problem from Fitzpatrick 2nd edition Advanced Calc textbook.
Consider: \begin{equation*} f(x) = \begin{cases} x^2 & x \leq 0 \\ x+1 & x > 0 \end{cases} \end{equation*} Where is f continuous?
Proof (by cases): Let $x_{0}\in \mathbb{R}$ be given. We will show that $f$ is continuous iff ${x_n}$ is a sequence in $\mathbb{R}$ that converges to $x_0$, then the image sequence $\{f(x_n)\}$ converges to $f(x_0)$.
Case 1: Suppose $x_{n} \longrightarrow x_{0} < 0$. Since $x_{n} \longrightarrow x_{0}$, we can choose an $\epsilon = -x_{0}/2$ which is greater than $0$ because $x_0<0$. By the definition of convergence, there exists an index $N$ such that $\lvert x_{n}-x_{0} \rvert < \epsilon = -x_{0}/2 $ for all indices $n$ with $n \geq N$. Thus, $x_0/2 < x_n - x_0 < -x_0/2$, and adding $x_0$ to both sides yields that $3x_0/2 < x_n < x_0/2 <0$, since $x_0 < 0$ implies that $x_0/2 <0$. Therefore since $x_n<0$, the image of $x_n$, $f(x_n) = x_n^2$ by definition. As a result, $f(x_n)$ converges to $x_0^2 = f(x_0)$. Therefore $f$ is continuous when $x < 0$.
Case 2: $x_{n} \longrightarrow x_{0} > 0$. We can choose an $\epsilon = x_0 >0$. Then by the defintion of convergence, there exists an index $N$ such that $\lvert x_{n}-x_{0} \rvert < \epsilon = x_0$ for all indices $n$ with $n \geq N$. Therefore $-x_0 < x_n -x_0 < x_0$ and thus, $0<x_n<2x_0$. Therefore $f(x_n) = x_n +1$. As result, $\{f(x_n)\}$ converges to $x_0 +1 = f(x_0)$. Therefore f is continuous when $x >0$.
Case 3: if $x_0 = 0$, then we can define a sequence $x_n = 1/n$ for all indices $n$ that converges to $x_0 = 0$. However, since $1/n$ is positive, we define $f(x_n) = (1/n) + 1$. But $f(x_n)$ conveges to $1 \neq 0 = f(x_0)$. Therefore $f$ is not continuous at $x_0 = 0$.
Let me know what you think about this proof.