How to show that $f(x)=|x^2-3x+2|$ is not differentiable at $x=1$ Consider the function
$$f(x)=|x^2-3x+2|$$
over the interval $[0,3]$. Intuitively I know that $f$ is not differentiable at $x=1$ but when I calculate the limits
$$\lim_{x\rightarrow 1^+} \frac{f(1+h)-f(1)}{h}\;\;\text{and}\;\;\lim_{x\rightarrow 1^-} \frac{f(1+h)-f(1)}{h},$$ I find they are equal and so by definition the limit
$$\lim_{x\rightarrow 1} \frac{f(1+h)-f(1)}{h}$$ exists and the function is differentiable at $x=1$. Have I made an error in my logic?
 A: Start with noticing that $x^{2} - 3x + 2 = (x - 1)(x - 2)$. Then we have that
\begin{align*}
\lim_{h\to 0^{+}}\frac{f(1 + h) - f(1)}{h} = \lim_{h\to 0^{+}}\frac{|h(h - 1)|}{h} = \lim_{h\to 0^{+}}\frac{h(1 - h)}{h} = 1
\end{align*}
On the other hand, we do also have that
\begin{align*}
\lim_{h\to 0^{-}}\frac{f(1 + h) - f(1)}{h} = \lim_{h\to 0^{-}}\frac{|h(h - 1)|}{h} = \lim_{h\to 0^{-}}\frac{h(h - 1)}{h} = -1
\end{align*}
Since the one sided limits are unequal, the proposed derivative does not exist.
Hopefully this helps !
A: You seem to be confusing two definitions of the derivative. On one hand, we have:
$$f'(x_0)=\lim_{h\to 0} \frac{f(x_0+h)-f(x_0)}{h}$$
and on the other, we have:
$$f'(x_0)=\lim_{x\to x_0} \frac{f(x)-f(x_0)}{x-x_0}.$$
That these two definitions are equivalent is obvious since you get from the first to the second via the substitution $x=x_0+h$.
So in your specific problem, you can either calculate
$$\lim_{h\rightarrow 0^+} \frac{f(1+h)-f(1)}{h}\;\;\text{and}\;\;\lim_{h\rightarrow 0^-} \frac{f(1+h)-f(1)}{h},$$
or else you can calculate
$$\lim_{x\rightarrow 1^+} \frac{f(x)-f(1)}{x-1}\;\;\text{and}\;\;\lim_{x\rightarrow 1^-} \frac{f(x)-f(1)}{x-1},$$
but the limit as you have written it is incorrect as it mixes the two forms.
Concretely,
$$\lim_{x\to 1^+} \frac{f(x)-f(1)}{x-1} = \lim_{x\to 1^+} \frac{|x^2-3x+2|-0}{x-1}=\lim_{x\to 1^+} \frac{|(x-1)\cdot(x-2)|}{x-1}$$
Since $x\to 1^+$ we can replace $|(x-1)\cdot(x-2)|$ by $-(x-1)(x-2)$, because on one hand $x>1$ so $(x-1)$ is positive, and on the other hand $x<2$ (for $x$ sufficiently close to $1$) so $(x-2)$ is negative, so the overall expression is negative and its absolute value is given by its negation. Therefore we get
$$\lim_{x\to 1^+} \frac{-(x-1)(x-2)}{x-1}=\lim_{x\to 1^+} -(x-2) = 1.$$
A similar calculation for $x\to 1^-$ will yield the limit $-1$, so that the one sided limits do not agree with one another, and the function is not differentiable at $x=1$.
A: Since $f(x) = \lvert x^2 - 3x + 2 \rvert = \lvert x-1 \rvert \, \lvert x-2 \rvert$,
we have $f(1+h) = \lvert h \rvert \, \lvert h-1 \rvert$. Since we're interested in values of $x$ near $1$, we can write $x = 1+h$, where $h$ is a small number. It will be useful to assume that $h<1$, and there's no loss of generality in assuming that. This assumption implies that $h-1<0$, so $\lvert h-1 \rvert = -(h-1) = 1-h$. Thus,
$$
f(1+h) = \lvert h \rvert \, (1-h), 
$$
which has different expansion, depending on the sign of $h$:
\begin{align}
h>0 \quad&\Longrightarrow\quad \lvert h \rvert = h \\
\quad&\Longrightarrow\quad 
\lim_{h \to 0^+} \frac{f(1+h) - f(1)}{h} 
= \lim_{h \to 0^+} \frac{h(1-h) - 0}{h} 
= \lim_{h \to 0^+} (1-h) = 1
\end{align}
but
\begin{align}
h<0 \quad&\Longrightarrow\quad \lvert h \rvert = -h \\
\quad&\Longrightarrow\quad 
\lim_{h \to 0^-} \frac{f(1+h) - f(1)}{h} 
= \lim_{h \to 0^-} \frac{-h(1-h) - 0}{h} 
= \lim_{h \to 0^-} (h-1) = -1. 
\end{align}
Since these one-sided limits don't agree, the derivative $f'(1)$ does not exist.
A: As an alternative to using the limit definition as do the other answers, if you already know $g(x)=|x|$ is not differentiable at $x=0$ and $g'(x)={x\over |x|},x\neq 0,$ then the result follows immediately by chain rule. Assuming by contradiction $f$ is differentiable at $x=1$, then
$$f'(1)={x^2-3x+2\over |x^2-3x+2|}(2x-3)\Bigg|_{x=1}$$
but this is not well defined.
