Distribution to density to expected

A random variable X has the cumulative distribution function

$\displaystyle F(x) = 0 $ for $\displaystyle x<1$

$\displaystyle F(x) = \frac{x^2 - 2x + 2}{2} $ for $\displaystyle 1 \leq x < 2$

$\displaystyle F(x) = 1 $ for $\displaystyle x \geq 2$

Calculate the variance of X.

The answer specifies that the density function is

$\displaystyle f(x) = 0.5 $ if x=1

$\displaystyle f(x) = x-1 $ if 1<x<2

$\displaystyle f(x) = 0 $ otherwise

Then

$\displaystyle E(X) = 0.5 + \int_1^2 x(x-1) dx$

$\displaystyle E(X^2) = 0.5 + \int_1^2 x^2(x-1) dx$

I got the f(x) = x-1 part, and I got how to calculate the variance after you have the expected values, but I'm lost on other questions.

My questions are:

**Where do we get $\displaystyle f(x) = 0.5 $ if x=1?** F(1) = 0.5, but I can't figure out why f(1) would equal 0.5.

**What is the rule for putting parts of the stepwise density function into the expected value equations?** I don't know what the rule is called so I don't know how to review it. We're adding the slope at a single point to the slope over a big area, which is something I can't quite work out visually.