Find variance of $X$ given its cumulative distribution function A rv $X$ has the cumulative distribution function
$$ F(x) = \begin{cases} 0 \; \; \; \; x<1 \\ \frac{x^2-2x+2}{2} \; \; \; \; 1 \leq x < 2 \\ 1 \; \; \; \; x \geq 2 \end{cases} $$
Calculate the variance of $X$
attempt
First since $F'(x) = f(x)$, then 
$$ f(x) = x-1 $$
on $[1,2)$ and $0$ otherwise. Now,
$$ Var(X) = E(X^2) - E(X)^2 = \int\limits_1^2 (x^3 - x^2) dx - \left( \int\limits_1^2 (x^2-x )\right)^2 $$
After solving this easy integral I get $0.73$ whereas my answer key says the answer is $\boxed{0.139}$. What is my mistake here? Am I applying the formulas wrong?

It doesn't have a density. Note that $F(1)=\frac12$. If you assume that there is a density and compute according  to your formula, you will notice that $E(X) <1$, which imply that something went wrong.
Let $y \in [1,4)$,$$P(X^2 \le y)=P(X \le \sqrt{y})=\frac{y-2\sqrt{y}+2}{2}$$
$$E[X^2]=\int_0^1 \, dx+\int_1^4 \frac{2\sqrt{x}-x}{2}\, dx=\left. \frac23x^\frac32-\frac{x^2}4\right|_1^4+1=1+\frac{14}{3}-\frac{15}4=1+\frac{56-45}{12}=\frac{23}{12}$$
$$E[X]=\int_0^1 \, dx + \int_1^2\frac{2x-x^2}{2}\, dx = \left. \frac{x^2}2-\frac{x^3}{6} \right|_1^2+1=1+\frac32-\frac76=\frac{4}{3}$$
Hence the variance is 
$$\frac{23}{12}-\frac{16}{9} \approx 0.139$$
