Expectation of a continuous random variable

I am looking at a math problem that is asking me to determine $\mathbb{E}[e^{X}]$ given that $X$ is a random variable, and the probability density function of $X$ is given by

$$f(x) =\begin{cases} 1 & 0 \leq x \leq 1 \\ 0 & \text{otherwise.} \end{cases}$$

The solution from the answer key is below:

Let $Y = e^{X}.$ Then we wish to determine $\mathbb{E}[Y]$. But first, we need to find the probability density function $f_{y}$ of $Y$. To do that, we begin with the probability cumulative distribution function $F_{Y}$ of $Y$:

\begin{align} F_{Y} = P\{Y \leq x\} \\ = P\{e^{X} \leq x\} \\ = P\{X \leq \log(x)\} \\ = \int_{0}^{\log(x)} f(y) \mathop{dy} \\ = \log(x). \end{align}

Differentiating, we obtain $f_{Y} = \dfrac{1}{x}$. Then we have $$\mathbb{E}[e^{X}] = \mathbb{E}[Y] = \int_{-\infty}^{\infty} xf_{Y}(x) \mathop{dx}$$

$$= e - 1.$$

My question:

I don't understand why the integrand is $f(y)$ and not $f(x)$ when we're determining $F_{Y}$. I thought $P\{X \leq \log(x)\} = \int_{-\infty}^{\log(x)} f_{X}(x)$, where $f_{X}$ is the probability density function of $X$.

• Limit of the integral depends on $x$, so it is better to use $y$ as a dummy variable instead of $x$ itself to avoid confusion. And when one writes $f(y)$, it means the exact same pdf of $X$ as defined in the beginning. Aug 4 '18 at 21:27
• Instead of finding the density of $Y$, it is simpler to say $E(e^X)=\int_0^1 e^x f(x)\,dx$ using the Law of the unconscious statistician. Aug 4 '18 at 21:31
• Your explanation makes sense. I did not know about that law. It looks much faster that way. Thank you!
– user381493
Aug 4 '18 at 22:08
• @StubbornAtom: I have never heard that theorem given a name. About as good as any, I guess! Aug 4 '18 at 22:17

The solution is confusing you by using $y$ for two different things. In the integral, $y$ is just a dummy variable. They could just as easily have used $t$ instead of $y$.