Exercise 8.15: Let $(X,Y)$ be a uniformly distriubted random point on the quadrilateral $D$ with vertices $(0,0), (2,0), (1,1),$ and $(0,1)$. What is the Covariance of $X$ and $Y$?
After numerous attempt I calculate Cov($X,Y) = \frac{83}{324}$ when the answer the book gives is $-\frac{13}{324}$. Intuitively, my answer does not make sense as I suspect there should be a negative correlation based on the shape of the quadrilateral.
Anyways below is my work:
First, after graphing the quadrilateral, we have that the area of the quadrilateral is $\frac{3}{2}$. Therefore, it follows from the uniform distributed nature of the points that \begin{equation*} f(x,y):=\begin{cases}\frac{2}{3}, \quad x \in \text{Quadrilateral},\\0, \quad\text{ otherwise}.\end{cases} \end{equation*} Given this, recall that Cov($X,Y$) = $E[XY] - E[X]E[Y]$. Now, we calculate $E[X]$: \begin{equation*} E[X] = \int_0^1\int_0^1\frac{2}{3}xdxdy + \int_1^2\int_0^{2-x}\frac{2}{3}xdydx = \frac{4}{9}. \end{equation*} Similarly, we calculate $E[Y]$: \begin{equation*} E[Y] = \int_0^1\int_0^1\frac{2}{3}ydxdy + \int_1^2\int_0^{2-x}\frac{2}{3}ydydx = \frac{1}{9}. \end{equation*} Lastly, \begin{equation*} E[XY] = \int_0^1\int_0^1 \frac{2}{3}xydxdy + \int_1^2\int_0^{2-x}\frac{2}{3}xydydx = \frac{11}{36}. \end{equation*} Thus, \begin{equation*} Cov(X,Y) = E[XY] - E[X]E[Y] = \frac{11}{36} - \frac{4}{9}\frac{1}{9} = \frac{83}{324}. \end{equation*}
Remark: Now, my only intuition regarding what I got wrong would be how I set up the expectations, perhaps since I computed the expectation by decomposing the quadrilateral into two easier computations (a square and triangle) I should have used different density functions for both? But I don't know if that should be the case.
Thanks to the comment from YJT, I realize that it was a computational error. The integrals were set up correctly, but I forgot to add the integrals for the squares into my expectation, i.e., while computing by hand I simply dropped a term.
Correction: \begin{equation*} E[X] = \int_0^1\int_0^1\frac{2}{3}xdxdy + \int_1^2\int_0^{2-x}\frac{2}{3}xdydx = \frac{1}{3} + \frac{4}{9} = \frac{7}{9}, \end{equation*} \begin{equation*} E[Y] = \int_0^1\int_0^1\frac{2}{3}ydxdy + \int_1^2\int_0^{2-x}\frac{2}{3}ydydx = \frac{1}{3} + \frac{1}{9} = \frac{4}{9}. \end{equation*}
With the already found $E[XY]$, it immediately follows that: \begin{equation*} Cov(X,Y) = E[XY] - E[X]E[Y] = \frac{11}{36} - \frac{7}{9}\cdot \frac{4}{9} = -\frac{13}{324} \end{equation*}