Calculate the variance of random variable $X$ A random variable has the cumulative distribution function $$F(x)=\begin{cases} 0 & x<1\\\frac{x^2-2x+2}{2}&x\in[1,2)\\1&x\geq2\end{cases}.$$ Calculate the variance of $X$.
First I differentiated the distribution function to get the density function, $f_X(x)=x-1$, for $x\in[1,2)$, and then I calculated $$E(X^2)-[E(X)]^2=\int_1^2x^2(x-1)dx-\bigg(\int_1^2x(x-1)dx\bigg)^2=\frac{13}{18}.$$
However, the correct answer is $\frac{5}{36}$. Why is that answer correct? I thought $var(X)=E(X^2)-[E(X)]^2$? 
Also, Merry Christmas!

A useful trick for non-negative random variables is to note that:
$E[X] = \int_0^\infty (1- F(x)) dx$
$E[X^2] = 2 \int_0^\infty x (1- F(x)) dx$
(These can be derived by integration by parts. No need to worry about point masses, which you have as André Nicolas pointed out.)
Thus, $E[X] = \int_0^1 1 dx + \int_1^2 (1- \frac{x^2-2x+2}{2}) dx$. Similarly, $E[X^2] = 2 \left( \int_0^\infty x dx+ \int_1^2 x(1- \frac{x^2-2x+2}{2}) dx \right)$.
Then, apply $var(X) = E[X^2] - (E[X])^2$ as you stated. 
