Continuous random square expectation

We can find the continuous random expectation using this formula:

E(X)=\int_a^b x\times f(x)\,\,dx

To find the expectation of X^2 then, we can just do:

E(X^2)=\int_a^bx^2\times f(x)\,\,dx

a and b represent the range of the continuous random variable.

Why do we just square the x^2?

We don’t square the f(x), because the X^2 in E(X^2) means the square of the values, not the probability.