Calculating Expectation and Covariance $X$ is a random variable which is uniformly distributed on the interval $[1,4]$. Define the random variable $Y = g(x)$ with $g(x) = x^2$

How can I calculate $E(g(X))$, $g(E(X))$ and the covariance Cov$[X,Y]$?

I would really appreciate it if someone can show me how to solve this !
The probability density function of $X$ is defined as

$$f_X(x) = \begin{cases}\frac13 &amp; 1\le x\le 4\\0&amp;\text{otherwise}\end{cases}$$

The expectation of $Y$, $E[Y] = E[g(X)]$ can be obtained by
$$\begin{align*}E[g(X)] &amp;= \int_{-\infty}^\infty g(x)\ f_X(x)\ dx\\
&amp;= \int_1^4x^2\cdot\frac13\ dx\\
&amp;= \frac13\int_1^4x^2\ dx\\
&amp;= \frac13\left[\frac{x^3}3\right]_1^4\\
&amp;= 7
\end{align*}$$



By symmetry of uniform distribution, $E[X]$ can be quickly calculated as
$$E[X] = \frac{4+1}2 = 2.5,$$
or not as quickly calculated by
$$E[X] = \int_1^4x\cdot\frac13\ dx = \frac13\left[\frac{x^2}2\right]_1^4 = 2.5.$$
Then $g(E[X]) = 2.5^2$.



The covariance $COV(X,Y) = E[(X-E[X])(Y-E[Y])]$,
$$\begin{align*}COV(X,Y) &amp;= E[(X-E[X])(Y-E[Y])]\\
&amp;= E[XY] - E[X]\cdot E[Y]\\
&amp;= \frac13\int_1^4 x^3\ dx - 2.5\cdot 7\\
&amp;= \frac13\left[\frac{x^4}4\right]_1^4 - 2.5\cdot 7\\
&amp;= 3.75
\end{align*}$$
Hints

You need
$$\mathbb{E}[g(X)] = \mathbb{E}[X^2]\\
g(\mathbb{E}[X]) = \mathbb{E}[X] \times \mathbb{E}[g(X)] \\
\textrm{Cov}(X,Y)
$$
can you get the first two?