Coding expectation of a product

Yes, exactly. See also
[Expectation of function,vs,function of expectations)
and
[Expected value of a power)