$X \sim Exp(\frac{1}{3}) $ If $Y= \max(X,2)$ Find $E(Y)$ $X \sim Exp(\frac{1}{3}) $ 
If $Y= \max(X,2)$ Find $E(Y)$
I did in two ways can anyone point out my mistake ? 
First one 
$f(y)=
\begin{cases}
\ 2,  & \text{if $0<x\le2$ } \\[2ex]
X, & \text{if $2<x<\infty$ }
\end{cases}$
$E(Y)=E(Y|0<x<2)P(0<x\le2)+E(Y|2<x<\infty)P(2<x<\infty)$
$E(Y)=2(1-e^{\frac{2}{3}})+e^{\frac{-2}{3}}\int \dfrac{x}{3}e^{-\frac{x}{3}} dx=2(1-e^{\frac{2}{3}})+\dfrac{e^{\frac{-2}{3}}}{3}\bigg(\bigg(-3xe^{-\frac{x}{3}}\bigg)_{2}^{\infty}-\bigg(9e^{-\frac{x}{3}}\bigg)_{2}^{\infty}\bigg)=2-2e^{\frac{-2}{3}}+\dfrac{e^{\frac{-2}{3}}}{3}\bigg(\bigg(6e^{-\frac{2}{3}}\bigg)+\bigg(9e^{-\frac{2}{3}}\bigg)\bigg)=2-2e^{-\frac{2}{3}}+5e^{-\frac{4}{3}}$
Second way
$E(Y)=\int \max(X,2)f(x)dx=\int_0^{2} 2f(x)dx+\int _{2}^{\infty}xf(x)dx=2(1-e^{\frac{-2}{3}})+\bigg(\bigg(-3xe^{-\frac{x}{3}}\bigg)_{2}^{\infty}-\bigg(9e^{-\frac{x}{3}}\bigg)_{2}^{\infty}\bigg)=2-2^{-\frac{2}{3}}+5e^{-\frac{2}{3}}=2+3e^{-\frac{2}{3}}$
Now I am not sure which of them is correct and why can anyone tell me ?
 A: In the first method, you are using the law of total expectation, namely $E(Y)=E\,[E(Y\mid X)]$.
Note that 
\begin{align}
E(Y)&=E(Y\mid X\le 2)P(X\le 2)+E(Y\mid X>2)P(X>2)
\\&=E(2\mid X\le 2)P(X\le 2)+E(X\mid X>2)P(X>2)
\\&=2P(X\le 2)+E(X\mathbf1_{X>2})\tag{1}
\end{align}
In the second approach, you are using this theorem to calculate 
expected value of any function of $X$ directly. I would suggest using this method here.
\begin{align}
E(\max(X,2))&=\frac{1}{3}\int \max(x,2)e^{-x/3}\mathbf1_{x>0}\,dx
\\&=\frac{2}{3}\int_0^2 e^{-x/3}\,dx+\frac{1}{3}\int_2^\infty xe^{-x/3}\,dx\tag{2}
\end{align}
$(1)$ and $(2)$ are saying the same thing of course.
Integrating by parts the second integral, indeed we get $E(Y)=2+3e^{-2/3}$
A: This is how I would proceed (similar to your second method):
$E(Y)=\int_0^22\times\frac{1}{3}e^{\frac{-x}{3}}dx + \int_2^\infty x\times\frac{1}{3}e^{\frac{-x}{3}}dx$
$=2(1-e^{\frac{-2}{3}}) +3\int_\frac{2}{3}^\infty t\times e^{-t}dt$
$=2(1-e^{\frac{-2}{3}}) +3\Gamma(2,\frac{2}{3})$
$=2+3e^{\frac{-2}{3}}$
Here is an easy tutorial to solve the incomplete Gamma Integral http://mathworld.wolfram.com/IncompleteGammaFunction.html
