How to calculate E(X|X+Y=a) for some given a? Suppose $X \sim exp(\lambda_1)$ and $Y\sim exp(\lambda_2)$. Than how to calculate 
$E(X | X+Y=a)$ for a given $a>0$. 
My try: 
$E(X | X+Y=a)=\int_0^\infty xP(X| X=a-Y)dx$
Then how to calculate  $P(X | X=a-Y)$.
Thanks in advance.
 A: Let $Z=X+Y.\;$ I'll assume independence of $X,Y$, otherwise we don't have enough information for a solution. Then,
\begin{eqnarray*}
E(X\mid Z=a) &=& E(E(X\mid Y,Z)\mid Z=a) \\
&=& \int_0^a{E(X\mid Y=y\cap Z=a) f_{Y|Z}(y|a)\;dy} \\
&=& \int_0^a{E(X\mid X=a-y\cap Y=y) f_{Y|Z}(y|a)\;dy} \\
&=& \int_0^a{(a-y) f_{Y|Z}(y|a)\;dy}.
\end{eqnarray*}
Now,
\begin{eqnarray*}
f_{Y|Z}(y|z) &=& \dfrac{f_{Y,Z}(y,z)}{f_{Z}(z)} \\
&=& \dfrac{f_{X,Y}(z-y,y)}{f_{Z}(z)} \\
&=& \dfrac{f_{X}(z-y)f_{Y}(y)}{f_{Z}(z)} \qquad\qquad\text{by independence of $X,Y$.} \\
\end{eqnarray*}
Two cases: (a) $\lambda_1 = \lambda_2$, and (b) $\lambda_1 \neq \lambda_2$.
(a) $\lambda_1 = \lambda_2$
\begin{eqnarray*}
f_Z(z) &=& \int_0^z{P(X=z-y)P(Y=y)\;dy} \\
&=& \int_0^z{f_X(z-y)f_Y(y)\;dy} \\
&=& \int_0^z{\lambda_1 e^{-\lambda_1 (z-y)} \lambda_1 e^{-\lambda_1 y}\;dy} \\
&=& \int_0^z{\lambda_1^2 e^{-\lambda_1 z}\;dy} \\
&=& \lambda_1^2 z e^{-\lambda_1 z} \\
&& \\
\therefore f_{Y|Z}(y|z) &=& \dfrac{\lambda_1^2 e^{-\lambda_1 z}}{\lambda_1^2 z e^{-\lambda_1 z}} \\
&=& \dfrac{1}{z}
&& \\
\therefore E(X\mid Z=a) &=& \int_0^a{\frac{a-y}{a}\;dy} \\
&=& \left[ y - \dfrac{y}{2a^2} \right]_0^a \\
&=& a - \dfrac{a}{2a^2} = \dfrac{a}{2}.
\end{eqnarray*}
This is what you might expect for the case $X,Y$ i.i.d.
(b) $\lambda_1 \neq \lambda_2$
This case is solved by similar procedure though the working is a little more tedious than for case (a). We get the result that
\begin{eqnarray*}
E(X\mid Z=a) &=& \dfrac{\frac{1}{\lambda_1 - \lambda_2} e^{-\lambda_2 a} - \left(a + \frac{1}{\lambda_1 - \lambda_2} \right) e^{-\lambda_1 a}}{e^{-\lambda_2 a} - e^{-\lambda_1 a}}.
\end{eqnarray*}
As a sanity check, when $\lambda_1 \ll \lambda_2$ we expect this value to be close to, but below, $a$: here $e^{-\lambda_1 a}$ dominates $e^{-\lambda_2 a}$ so $E(X\mid Z=a) \approx a + \frac{1}{\lambda_1 - \lambda_2}$.
Also, when $\lambda_1 \gg \lambda_2$ we expect this value to be close to, but above, $0$: here $e^{-\lambda_2 a}$ dominates $e^{-\lambda_1 a}$ so $E(X\mid Z=a) \approx \frac{1}{\lambda_1 - \lambda_2}$.
A: No, you were on the right track, using the Law of Iterated Expectation.  
For some condition $\mathcal A$,  the LIE is:
$\mathsf E_X(X\mid \mathcal A) = \mathsf E_Y(\mathsf E_{X\mid Y}(X\mid \mathcal A, Y)\mid \mathcal A)$

$$\begin{align}
\mathsf E(X\mid X+Y=a) & = \mathsf E(\mathsf E(X\mid X=a-Y, Y)\mid X+Y=a)
\\ & = \int_0^a \mathsf E(X\mid X=a-y, Y=y)\;f_Y(y\mid X+Y=a)\operatorname d y
\\ & = \int_0^a (a-y) f_{Y}(y\mid X+Y=a)\operatorname dy
\\ & = \frac{\int_0^a(a-y)\;f_{X,Y}(a-y,y) \operatorname d y}{\int_0^a f_{X,Y}(a-t,t)\operatorname dt}
\\ & = a-\frac{\int_0^a y\;f_{X,Y}(a-y,y) \operatorname d y}{\int_0^a f_{X,Y}(a-t,t)\operatorname dt}
\end{align}$$
Now, if $X$ and $Y$ are independent we have:
$$\begin{align}
\mathsf E(X\mid X+Y=a)
 & = \frac{\int_0^a \lambda_1\lambda_2 (a-y)\;e^{-\lambda_1(a-y)}e^{-\lambda_2 y} \operatorname d y}{\int_0^a \lambda_1\lambda_2 e^{-\lambda_1(a-t)}e^{-\lambda_2 t}\operatorname dt}
\\[2ex]
 & = \frac{\int_0^a (a-y)\;e^{(\lambda_1-\lambda_2)y} \operatorname d y}{\int_0^a  e^{(\lambda_1-\lambda_2)t}\operatorname dt}
\\[2ex]
 & =\begin{cases} a-\dfrac{1+(a(\lambda_1-\lambda_2)-1)e^{a(\lambda_1-\lambda_2)}}{(\lambda_1-\lambda_2)(e^{a(\lambda_1-\lambda_2)}-1)} & \mbox{if }\lambda_1\neq\lambda_2
\\[1ex] a/2 & \mbox{if }\lambda_1=\lambda_2\end{cases}
\\[2ex] & =\begin{cases} \dfrac 1{\lambda_1-\lambda_2}-\dfrac{a}{e^{a(\lambda_1-\lambda_2)}-1} & \mbox{if }\lambda_1\neq\lambda_2
\\[1ex] a/2 & \mbox{if }\lambda_1=\lambda_2\end{cases}
\end{align}$$
