Show that random variables $X$ and $Y$ are not independent, but nevertheless Cov$[X,Y] = 0$

It is not necessary to find these functions.

To prove dependency it is enough to find sets $A,B$ such that $$P(X\in A\wedge Y\in B)\neq P(X\in A)P(Y\in B)$$

To prove that the covariance is $0$ it is enough to show that $$\mathbb EXY=\mathbb EX\mathbb EY$$

and for that you do not need the PDF's either.

E.g. note that: $$\mathbb EXY=\int_0^1\sin2\pi z\cos2\pi z~\mathrm dz$$


There is an easier way. It is sufficient to show that $P(X\in A,Y\in B)\neq P(X\in A)P(Y\in B)$ for some sets $A,B$. For example You can take $A=B=[0.9,1]$.


A routine integration gives you $E(X)=E(Y)=E(XY)=0$, so that $\mathrm{Cov}(X,Y)=0$. That is, $X$ and $Y$ are uncorrelated.

But $X$ and $Y$ are not independent since if a value of $X$ is known, then $Z$ is one of two possible values, which implies $Y$ is also one of two values. In other words, the conditional distribution of $Y\mid X$ is not the same as the distribution of $Y$.


Since the probability has been covered, I'm going to look at the covariance.

Observe that $$\text{Cov}(X, Y) = \mathbb{E}[XY]-\mathbb{E}[X]\mathbb{E}[Y]$$ so that $$\text{Cov}(X, Y) = \mathbb{E}[\sin(2\pi Z)\cos(2\pi Z)] - \mathbb{E}[\sin(2\pi Z)]\mathbb{E}[\cos(2\pi Z)]$$ Recall the trigonometric identity $$\sin(2\theta) = 2\sin(\theta)\cos(\theta)$$ Thus, $$\sin(4\pi Z) = 2\sin(2\pi Z)\cos(2\pi Z) \implies \dfrac{\sin(4\pi Z)}{2}=\sin(2\pi Z)\cos(2\pi Z)$$ hence the covariance is $$\begin{align}\text{Cov}(X, Y) &= \mathbb{E}\left[\dfrac{\sin(4\pi Z)}{2}\right] - \mathbb{E}[\sin(2\pi Z)]\mathbb{E}[\cos(2\pi Z)] \\ &= \dfrac{1}{2}\mathbb{E}\left[\sin(4\pi Z)\right]-\mathbb{E}[\sin(2\pi Z)]\mathbb{E}[\cos(2\pi Z)]\text{.} \end{align}$$ Since the density function $f_Z(z) = 1$ for $z \in [0, 1]$, we have $$\begin{align}\text{Cov}(X, Y) &= \dfrac{1}{2}\mathbb{E}\left[\sin(4\pi Z)\right]-\mathbb{E}[\sin(2\pi Z)]\mathbb{E}[\cos(2\pi Z)] \\ &= \dfrac{1}{2}\int_{0}^{1}\sin(4\pi z)\text{ d}z - \left[\int_{0}^{1}\sin(2\pi z)\text{ d}z \right]\left[\int_{0}^{1}\cos(2\pi z)\text{ d}z \right] \\ &= \dfrac{1}{2(4\pi)}\int_{0}^{4\pi}\sin(\theta)\text{ d}\theta - \dfrac{1}{(2\pi)^2}\left[\int_{0}^{2\pi}\sin(\theta)\text{ d}\theta \right]\left[\int_{0}^{2\pi}\cos(\theta)\text{ d}\theta \right] \tag{*}\\ &= \dfrac{-1}{8\pi}[\cos(4\pi)-\cos(0)]-\dfrac{-1}{4\pi^2}[\cos(2\pi)-\cos(0)][\sin(2\pi)-\sin(0)] \\ &= \dfrac{-1}{8\pi}(1-1)+\dfrac{1}{4\pi^2}(1-1)(0-0) \\ &= 0\text{.} \end{align}$$ In step $(*)$, I applied appropriate substitutions.