I am currently studying probability theory. I have done the basics of measure theory. I am about to ask a question about defining the domain of covariance in probability theory.
Suppose a probability space $(\Omega,\, \mathcal{F},\, P)$. Let $X: \Omega \to \mathbb{R}$ be a (real-valued) random variable. Expected value of $X$, denoted by $\mathrm{E}[X]$, can be given as the Lebesgue integral expression $$ \mathrm{E}[X] := \int_\Omega X \,dP \,. $$ Since by definition, a random variable has to be a measurable function, then the Lebesgue integral expression above is well-defined. However, we might have either $\mathrm{E}[X] < \infty$ or $\mathrm{E}[X] = \infty$. Let $p \in [1,\, \infty)$. If $X$ is an $L^p$-function, then we will have $$ \mathrm{E}[\,|X|^p\,]^\frac{1}{p} = \left( \int_\Omega |X|^p \,dP \right)^{1/p} < \infty \,. $$
Now I would like to express covariance as a mapping. Let $Y: \Omega \to \mathbb{R}$ be another random variable. The covariance of $X$ and $Y$ is given by $$ \mathrm{cov}(X, Y) := \mathrm{E}[(X - \mathrm{E}[X])(Y - \mathrm{E}[Y])] \,. $$ By applying the properties of Lebesgue integral (including $\sigma$-additive property), we will have $$ \mathrm{cov}(X, Y) = \mathrm{E}[XY] - \mathrm{E}[X]\mathrm{E}[Y] \,. $$ Now suppose we are evaluating the covariance of random variable $X$ with itself, and by applying the expression above, we will have $$ \mathrm{cov}(X, X) = \mathrm{E}[X^2] - \mathrm{E}[X]^2 \,, $$ which is also known as the variance of $X$.
We can see that the expression above will fall apart if (i) $\mathrm{E}[X^2] < \infty$ and (ii) $\mathrm{E}[X]^2 < \infty$ do not hold. If (i) holds, it implies that $X \in L^2$. And if (ii) holds, then $X \in L^1$. From this point, please correct me if I am wrong. Since (i) and (ii) have to hold in order $\mathrm{E}[X^2] - \mathrm{E}[X]^2$ to hold, then we could presume that covariance is a map $$ \mathrm{cov}: L^1 \cap L^2 \times L^1 \cap L^2 \to \mathbb{R} $$ couldn't we?
I would really appreciate any constructive argument and explanation. If my question is somewhat ridiculous, please tolerate me. I am still learning. Thank you.
The condition $E[X^2]<\infty$ implies $(E[X])^2<\infty$, by Cauchy-Schwarz, and if $X,Y\in L^2$ then $XY$ is integrable and so $\operatorname{Cov}(X,Y)$ has a finite value. And $\operatorname{Var}(X) = \operatorname{Cov}(X,X)=E[X^2]-(E[X])^2$ is finite. So you can think of $\operatorname{Cov}$ as a map from $L^2\times L^2$ to $\mathbb R$, and $\operatorname{Var}$ as a map from $ L^2$ to $\mathbb R$. (For real-valued r.v.s, of course.)