Let $X$ have the density $f_X(t) = \frac19 t^2$ in $[0, 3]$ and $Y = X^3$. Find $\operatorname{E}(Y)$ and $\operatorname{Var}(Y)$.
If $Y = g(X)$, the density of $Y$ is given by $f_Y(t) = \left( g^{-1} \right)' (t) \cdot f_X \left( g^{-1}(t) \right)$ so $Y$ is uniformly distributed in $[0, 27]$ which means $\operatorname{E}(Y) = \frac{27}2$ and $\operatorname{Var}(Y) = \frac{243}4$.
One could also find $\operatorname{E}(Y)$ using the law of the unconscious statistician
$$\operatorname{E} \big( g(X) \big) = \int_{\mathbb R} g(t) f_X(t) \text{ d}t$$
and knowing that
$$\operatorname{Var}(Y) = \int_{\mathbb R} \big( t - \operatorname{E}(Y) \big)^2 f_Y(t) \text{ d}t$$
my classmate used
$$\int_{\mathbb R} \big( g(t) - \operatorname{E}(Y) \big)^2 f_X(t) \text{ d}t$$
to calculate $\operatorname{Var}(Y)$. For every example I have tried, this does result in the correct value but I have been unable to find a derivation for this formula. For the example above,
$$\int_0^3 \left( t^3 - \frac{27}2 \right)^2 \cdot \frac19 t^2 \text{ d}t = \frac{243}4$$
It also captures the familiar $\operatorname{Var}(aX + b) = a^2 \operatorname{Var}(X)$ since
$$\int_{\mathbb R} \big( at+b - \operatorname{E}(aX+b) \big)^2 f_X(t) \text{ d}t = \int_{\mathbb R} \big( at+b - a\operatorname{E}(X) - b \big)^2 f_X(t) \text{ d}t $$ $$= a^2 \int_{\mathbb R} \big( t - \operatorname{E}(X) \big)^2 f_X(t) \text{ d}t$$
Any resources on this are highly appreciated.
Both expressions for the variance are equal. Starting from
$$\int_a^b \big( g(x) - \operatorname E(Y) \big)^2 f_X(x) \text{ d}x$$
substitute $y=g(x)$ which means $\text dx = \frac{\text dy}{g'(x)}$ and $x = g^{-1}(y)$
$$\int_{g(a)}^{g(b)} \big( y - \operatorname E(Y) \big)^2 f_X \big( g^{-1}(y) \big) \; \frac{\text dy}{g' \big( g^{-1}(y) \big)}$$
which can be rewritten using $$\displaystyle f_Y(t) = (g^{-1})'(t) \cdot f_X \big( g^{-1}(t) \big) = \frac{f_X \big( g^{-1}(t) \big)}{g' \big( g^{-1}(y) \big)}$$
leading to $$\int_{g(a)}^{g(b)} \big( y - \operatorname E(Y) \big)^2 f_Y(y) \text{ d}y = \operatorname{Var}(Y)$$