Computing an expectation of a function of an rv $E(f(X))$
I am self-learning undergrad calculus-based probability from Intro to Probability, Blitzstein and Hwang. I would like to ask, if the below deduction is correct.
Let $X \sim Geom(p)$ and define the function $f$ by $f(x) = P(X = x)$ for all real $x$. Find $E(f(X))$.
Solution. (My attempt)
$f(x) = (1-p)^x p$. So, the random variable $Y = f(X) = (1 - p)^X p$.
$Y$ takes values in the set $\{p,qp,q^2p,q^3p,\ldots\}$. The PMF of $Y$ is given by,
\begin{align*} P(Y = y) &= P((1-p)^X p = y)\\ &= P(X \log q = \log y - \log p)\\ &= P\left(X = \frac{\log y - \log p}{\log q}\right)\\ &= q^{\frac{\log y - \log p}{\log q}}\times p\\ &= \frac{q^{\log_q y}}{q^{\log_q p}}\times p\\ &= \frac{y}{p} \cdot p\\ &= y, \quad \quad y \in \{p,qp,q^2p,q^3p,\ldots\} \end{align*}
\begin{align*} E(Y) &= \sum_{y}yP(Y =y)\\ &= \sum_y y^2 \\ &= p^2 + p^2 q^2 + p^2 q^4 + \ldots \\ &= \frac{p^2}{1 - q^2}\\ &= \frac{p^2}{p(1+q)}\\ &= \frac{p}{2 - p} \end{align*}
Looks correct, but you can shortcut it by appealing to LOTUS:
$$E[q^Xp]=\sum_{x=0}^\infty (q^{x}p)(q^{x}p)=\sum_{x=0}^\infty q^{2x}p^2=\frac{p^2}{1-q^2} $$