# Expectation of 2 functions with one random variable

This may be a trivial question but I want to consult with you all.

Let U be a continuous random variable taking values int he interval [0,2pi]. Let X = cos(U), Y = sin(U). Determine the Pearson correlation between X and Y.

How to calculate the E[XY]?

Using the identity $\sin(2U) = 2\sin(U)\cos(U)$, we get:

$\displaystyle\mathbb{E}[XY] = \mathbb{E}[\sin(U)\cos(U)] = \mathbb{E}\left[\frac{\sin(2U)}{2}\right] = \frac{1}{2}\mathbb{E}\left[\sin(2U)\right] = \frac{1}{2}\int_0^{2\pi}\frac{1}{2\pi}\sin(2\theta)d\theta = \frac{1}{8\pi}\int_0^{4\pi}\sin(x)dx = 0$

### Solution by regression

This argument requires some geometric intuition and knowing that the Pearson correlation is proportional to the linear regression coefficient of $Y$ against $X$.

As $U$ ranges from $0$ to $2\pi$, $(X,Y)$ describes a circle, covering the upper half of the circle in the same way it covers the lower half. Thus the conditional distribution of $Y$ given $X$ is symmetric about $0$, forcing the regression line to be $Y=0$, implying the correlation is zero, whence the covariance is zero, too. Since (by circular symmetry) both $X$ and $Y$ have zero expectations, the covariance is merely $\mathbb{E}(XY)$ and we're done.

### Solution by circular symmetry

That had a hand-waving intuitive flavor to it. Maybe we can do a little better. Here's a more elaborate version of the same idea. It doesn't require knowing about regression.

Changing $U$ to $-U$ does not change the distribution of $(X,Y)$: it only causes $(X,Y)$ to traverse the circle clockwise rather than counterclockwise and the circle is still covered uniformly because the distribution of $-U$ is uniform between $-2\pi$ and $0$. But changing $U$ to $-U$ leaves $X$ alone and converts $Y$ to $-Y$. Because the distribution is unchanged, the expectations remain the same, too: $$\mathbb{E}(XY)=\mathbb{E}(X(-Y)) = -\mathbb{E}(XY).$$ Since $|XY|$ is bounded, the expectation of $XY$ exists and is finite, whence the only possible value of its expectation is zero.

### Solution by algebra and (very simple) trigonometry

OK, maybe that doesn't seem sufficiently rigorous. Here's another approach.

Cosine and sine depend only on $U$ up to a multiple of $2\pi$. Therefore you may allow $U$ to range uniformly over any interval of length $2\pi$, such as from $\pi/2$ to $\pi/2+2\pi$. That's equivalent to adding the start of the interval, $\pi/2$, to $U$. In light of this, notice that

$$X = \cos(U)\text{ becomes } \cos(U+\pi/2) = \sin(U) = -Y$$

and

$$Y = \sin(U)\text{ becomes } \sin(U+\pi/2) = \cos(U) = X$$

The expectation of $(X+Y)^2$ thereby becomes

\eqalign{ \mathbb{E}(X^2+Y^2) + \mathbb{E}(2XY) &= \mathbb{E}((X+Y)^2) \\ &= \mathbb{E}((-Y+X)^2) = \mathbb{E}(X^2+Y^2) + \mathbb{E}(-2XY). }

(These equations are the consequences of straightforward algebraic relationships $(X\pm Y)^2 = X^2+Y^2\pm 2XY$ and the linearity of expectation.)

Subtracting the right from the left and dividing that by $4$ yields

$$\mathbb{E}(XY) = 0,$$

QED.