Why this limit of integration? I've been solving problems from the book by DeGroot and Schervish and I can't understand why m is the upper limit of integration in the solution to this problem. Why not the lower one?
Here is the problem: 
Suppose that a random variable X has a continuous distribution for which the p.d.f. f is as follows:
$f(x) = 2x$ for $ 0< x <1, 0 $ otherwise
Determine the value of $d$ that minimizes $E(|X − d|)$.
Here is the solution:
$$ \int_0^m 2x \, dx=0.5  $$
Thank you very much in advance.
 A: The value of $d$ that that minimizes $E(|X-d|)$ is the median value of $X$, i.e. the value $m$ such that
$$
\Pr(X\le m) = 0.5 = \Pr(X\ge m).
$$
Thus for continuous distirbutions it is the value of $m$ for which
$$
\int_{-\infty}^m f_X(x)\,dx = 0.5 = \int_m^\infty f_X(x)\,dx.
$$
In your case, you want
$$
\int_0^m 2x\,dx = 0.5 = \int_m^1 2x\,dx.
$$
So $m^2 -0^2 = 0.5 = 1^2-m^2$.  Consequently $m= \sqrt{0.5}= \sqrt{2}/2$.
A: I will note one important thing about the question. You will get $$E^{'}[X]=1-2d^2$$ as @nbubis wrote down already. When you find $$E^{''}[X]=-4d$$ and since $d\in[0,1]$ you have $$E^{''}[X]<0$$ which indicates that you have a maximum instead of minimum as you stated in the question
EDIT: Result was based on $$E^{'}[X]=1-2d^2$$ Since it is $$E^{'}[X]=2d^2-1,$$ there is a minimum. I didnt solve the first derivative by myself just copied.
A: The expected value is given by (assuming $d$ is in $[0,1]$):
$$E = \int_0^1{2x|x-d|}dx = \int_0^d{2x(d-x)}dx + \int_d^1{2x(x-d)}dx$$
$$ = -\frac{2}{3} + d - \frac{2d^3}{3}$$
Derive by $d$ and compare to zero:
$$E' = 1 - 2d^2 = 0 \rightarrow d = \frac{1}{\sqrt{2}}$$
