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!