Let $f(x)$ be a function such that $$f(x)=\begin{cases}
x^2-2x+m & (\text{for $x\le 1$}) \\
mx-2m+3 & (\text{for $x>1$})
\end{cases}$$
Find interger values of $m$ for $\min f(x)\ge -1$
My try:
If $$x\le 1\rightarrow f'\left(x\right)=2x-2=0\Leftrightarrow x=1\rightarrow f'(1)=m-1$$ If $$x>1\rightarrow f'\left(x\right)=m$$ Then $\min f\left(x\right)=\min \left\{m-1;m\right\}=m-1$
So let $\min f(x)\ge -1\Leftrightarrow m-1\ge -1\Leftrightarrow m\ge 0$
$\forall m\in \mathbb{Z}^+$ we have $\min f(x)\ge -1$
Is it true? Help me solve it if its totally wrong. Thank you.
It is easy, computing the derivative of $f$ on $(-\infty,1]$, to see that $f$ is decreasing on $(-\infty,1]$.
Moreover, $f(1)=m-1$, so $\min f(x) \leq m-1$. So you must have $m\geq 0$ to have $\min f(x) \geq -1$.
Now, for $m \geq 0$, the function $f$ is increasing on $(1, +\infty)$. Moreover, $\lim_{x \rightarrow 1^+} f(x) = -m+3$. So $\min f(x) \leq -m+3$. So you must have $m \leq 4$ to have $\min f(x) \geq -1$.
Finally, you get that the condition on $m$ to have $\min f(x) \geq -1$ is $$m \in \lbrace 0,1,2,3,4 \rbrace$$