continuity and differentiability of $f(x)=\int^{1}_{0}|x-t|tdt$ 
Finding continuity and differentiability for $$f(x)=\int^{1}_{0}|x-t|tdt$$

What i try:
$\displaystyle f(x)=\int^{x}_{0}(x-t)tdt+\int^{1}_{x}(t-x)dt$
$\displaystyle =\bigg(\frac{xt^2}{2}-\frac{t^3}{3}\bigg)\bigg|^{x}_{0}+\bigg(\frac{t^3}{3}-\frac{xt^2}{2}\bigg)\bigg|^{1}_{x}$
$\displaystyle f(x)=\frac{1}{6}\bigg(2x^3-3x+2\bigg)$
Because $f(x)$ is a polynomial function of degree three. So it is continuous and differentiable for all real $x$
But answer given as
Function continuous for all real $x$ but not differentiable for all $x\in\mathbb{R}.$
Whats wrong with my solution. Please help me. Thanks
 A: One way is to consider three cases $x \le 0$, $x \in (0,1)$
and
$x \ge 1$ and compute $f$ for each case. Then check that the right and left hand values agree for the functions and their derivatives at $x=0$ and $x=1$.
Let $g_1(x)={1 \over 6}(2-3x)$, $g_2(x)= {1\over 6}(2x^3-3x+2)$ and
$g_3(x)= -g_1(x)$.
If $x\le 0$ then $f(x) = g_1(x)$.
If $x \in (0,1)$ then $f(x) = g_2(x)$.
If $x \ge 1$ then $f(x) = g_3(x)$.
It is straightforward to check that $g_1(0) = g_2(0) = {1 \over 3}$ and $g_2(1) = g_3(1)= {1 \over 6}$ and so $f$ is continuous.
It is straightforward to check that $g_1'(0) = g_2'(0) = -{1 \over 2}$ and $g_2'(1) = g_3'(1) = {1 \over 2}$ and so $f'$ is differentiable.
A: Here is a way to differentiate under the integral sign. I am just curious. It is not necessary for such easy integral. In fact, I prefer the direct solution in this case.
Assume:

*

*$g:\mathbb R\times [0,1]\to \mathbb R$ is measurable,

*$g(x,\cdot)$ is integrable for every $x\in \mathbb R$,

*$g(\cdot, t)$ admits a common Lipschitz constant $L$ for almost every $t\in[0,1]$, and

*$g(\cdot, t)$ is partially differentiable in the first argument at some  $a\in\mathbb R$ for almost every $t\in [0,1]$.

We want to prove that

$f(x) = \int_0^1 g(x, t) dt$ is differentiable at $a$.

We have
$$ \lim_{x\to a} \frac{f(x) - f(a)}{x - a} = \lim_{x\to a} \int_0^1 \frac{g(x, t) - g(a, t)}{x - a} dt. $$
As the integrand on the right-hand-side is bounded by the Lipschitz constant $L$ almost everywhere, the dominated convergence theorem applies, and we can push the limit operator under the integral sign.
It follows
$$ f'(x) = \int_{0}^1 \frac\partial{\partial x} g(a, t). $$
Obviously, for $g(x, t) = |x-t|$ all the assumptions are met.
Aside: You can even replace assumption 3 with a more complicate but weaker assumption: There is some $\varepsilon > 0$ such that
$$ \sup_{x\in (a-\varepsilon, a+\varepsilon)} \left| \frac{g(x, t) - g(a, t)}{x - t} \right| $$
is integrable on $[0, 1]$.
