Need help to understand the equation Here is a small equation, which says 
$$E[min\{{D, Q}\}] = \int_{0}^{Q}{xf(x)dx} + \int_{Q}^{\infty}{Qf(x)dx}$$, where D is a continuous random variable denoting the demand on a specific day and f(x) is the representative density function of demand D. Q represents the Quantity to be ordered.
Which is said to be equivalent of $$min(Q, D) = D − (D − Q)^+$$
Can someone tell me how is the integral representation is an equivalent of the avove representation? 
Thanks
-Kamal.

We have
$$\mathbb E[\min(D,Q)] = \int_0^\infty \min(x,Q)f(x)\mathsf dx. $$
For $x<Q$, $\min(x,Q)=x$, and for $x>Q$, $\min(x,Q)=Q$. So the above is equal to
$$\int_0^Q xf(x)\mathsf dx + \int_Q^\infty Qf(x)\mathsf dx. $$
Recall that $(D-Q)^+=\max(D-Q,0)$, and $\max(x-Q,0)=x-Q$ for $x>Q$. So
$$
\begin{align*}
\mathbb E[D]-\mathbb E[\max(D-Q,0)] &= \int_0^\infty xf(x)\mathsf dx-\int_0^\infty\max(x-Q,0)f(x)\mathsf dx\\
&= \int_0^Q xf(x)\mathsf dx + \int_Q^\infty xf(x)\mathsf dx - \int_Q^\infty (x-Q)f(x)\mathsf dx\\
&= \int_0^Q xf(x)\mathsf dx +\int_Q^\infty Qf(x)\mathsf dx.
\end{align*}  $$
