I am working on the following problem:
Let $X$ be a random variable of the continuous type that has pdf $f(x)$. If $m$ is the unique median of the distribution of $X$ and $b$ is a real constant, show that $$E(|X-b|)=E(|X-m|)+2\int_{m}^{b} (b-x)f(x)dx,$$ provided that the expectations exist.
Since $X$ has a pdf of $f(x)$, I know that the expectation of $E(|x-b|)$ is defined as $$E(|x-b|)=\int_{-\infty}^\infty |x-b|f(x)dx.$$ Where I'm getting stuck is the step that immediately follows this. Specifically, the solution provided shows:
$$\int_{-\infty}^\infty |x-b|f(x)dx=\int_{-\infty}^b(b-x)f(x)dx+\int_{b}^\infty (x-b)f(x)dx.$$ What is happening in this step?
They are splitting up the integral into two integrals corresponding to the two cases: