I need to prove that $f(x)=\begin{cases}|x|, & \text{when } x \leq 0\\ x^2, & \text{when } x > 0 \end{cases}$ is continuous with $\varepsilon$-$\delta$.
I have a solution for this but I don't understand why we should choose the delta in the following way.
When we assume that $x_0 <0$ and then choose $\delta = \min\{-x_0,\varepsilon\}$ we get $|f(x)-f(x_0)|=|x-x_0|<\varepsilon$, when $|x-x_0|< \delta$.
Why don't we just choose $\delta = \varepsilon$? Where do we need the $-x_0$?
Same is done when we consider $x_0 > 0$ and we choose $\delta = \min \{1, x_0, \varepsilon / (2|x_0|+1)\}$. And again same question: Why we need to take $x_0$ here in the minimum?
Hint: What is $f(x)$ when $|x-x_0|>-x_0$?