Absolute error loss minimization From Robert (The Bayesian Choice, 2001), it is proposed that the Bayes Estimator associated with the prior distribution $\pi$ and the multilinear loss is a $(k_2/(k_1+k_2))$ fractile of $\pi(\theta|x)$.
The proof follows that
$$
E^\pi[L_{k_1,k_2}(\theta,d|x)] = k_1\int\limits_{-\infty}^{d} (d-\theta)\pi(\theta|x)d\theta + k_2\int\limits_{d}^{+\infty}(\theta-d)\pi(\theta|x)d\theta
$$
Then, using the identity
$$
\int\limits_{c<y} (y-c)f(y)dy = P(y>c)
$$
I would get to
$$
E^\pi[L_{k_1,k_2}(\theta,d|x)] = k_2P^\pi(\theta>d|x) - k_1P^\pi(\theta<d|x)
$$
But he gets to
$$
E^\pi[L_{k_1,k_2}(\theta,d|x)] = k_1\int\limits_{-\infty}^{d} P^\pi(\theta<y|x)dy +  k_2\int\limits_{d}^{+\infty} P^\pi(\theta>y|x)dy
$$
And then takes the derivative in $d$. What am I'm missing, and why he does this last step? Thanks!
 A: Using his notation, for the loss defined by 
$$ L_{k_1,k_2}(\theta,d) =
     \begin{cases}
     k_2(\theta-d) & \textrm{if $\theta>d$,} \\
     k_1(d-\theta) & \textrm{otherwise,}
    \end{cases}
$$
Robert uses this identity to get 
$$ E^\pi[L_{k_1,k_2}(\theta,d)\mid x] = k_1\int\limits_{-\infty}^{d} P^\pi(\theta<y\mid x)\,dy +  k_2\int\limits_{d}^{+\infty} P^\pi(\theta>y\mid x)\,dy\, .$$
You want the decision $d$ which minimizes this expectation, so you take the derivative with respect to $d$ and make it equal to zero, which gives
$$ \frac{\partial E^\pi[L_{k_1,k_2}(\theta,d)\mid x]}{\partial d} = k_1 P^\pi(\theta<d\mid x) -k_2 P^\pi(\theta>d\mid x) = 0 \, ,$$
where we've used the Fundamental Theorem of Calculus, and this is equivalent to
$$ P^\pi(\theta<d\mid x) = \frac{k_2}{k_1 + k_2} \, , $$
as desired.
A: I think the book could be wrong but here's how I got to my answer:
\begin{align}
 E^\pi[L_{k_1,k_2}(\theta,d)\mid x] &= k_1\int\limits_{-\infty}^{d} (d-\theta)\pi(\theta|x)\, d\theta\, +  k_2\int\limits_{d}^{+\infty} (\theta-d)\pi(\theta|x) \,d\theta\, \\ 
&= k_1\int\limits_{-\infty}^{d} d\pi(\theta|x)\, d\theta\, +  
k_1\int\limits_{-\infty}^{d} -\theta\pi(\theta|x)\,d\theta\, \\  &+k_2\int\limits_{d}^{+\infty} \theta\pi(\theta|x) \,d\theta\, + 
k_2\int\limits_{d}^{+\infty} -d\pi(\theta|x) \,d\theta\,\\
&=k_1 dP^\pi(\theta < d|x) + k_1\int\limits_{-\infty}^{d} -\theta\pi(\theta|x)\,d\theta\, \\
&+ k_2\int\limits_{d}^{+\infty} \theta\pi(\theta|x) \,d\theta\, - k_2dP^\pi(\theta > d|x)
\end{align}
Taking the derivative in $d$ on both sides, we get
\begin{align}
\frac{\partial E^\pi[L_{k_1,k_2}(\theta,d)\mid x]}{\partial d} &= k_1 P^\pi(\theta<d\mid x)  + k_1d\pi(d|x) - k_1d\pi(d|x) \\ &+ k_2 d\pi(d|x) -k_2 P^\pi(\theta>d\mid x) - k_2d\pi(d|x) \quad \text{(using Leibniz's rule)}\\
&=k_1P^\pi(\theta<d|x) -k_2P^\pi(\theta>d|x) \\
&=0
\end{align}
