# Find the expected value $E[\theta]$ for a point in a unit square

A point $$(X,Y)$$ is uniformly distributed on the unit square $$[0,1]^2$$. Let $$\theta$$ be the angle between the x-axis and the line segment that connects $$(0,0)$$ to the point $$(X,Y)$$. Find the expected value $$E[\theta]$$.
The question also gives the hint that $${d\cos\theta\over d\theta}= {-\sin\theta}$$, $${d\tan\theta\over d\theta}= {1\over \cos^2\theta}$$.

Here is what I did:
Let: $$Z=\tan\theta={Y\over X}$$.
Here I assume X and Y are independent since coordinate in x-axis doesn't depend on y-axis.
Since $$f_X(x)=1$$, $$f_Y(y)=1$$, $$f_{X,Y}(x,y)=1$$. $$0\le x\le1$$, $$0\le y\le1$$. I get:
$$f_Z(z)={z\over2}, 0\lt z\lt1$$ $$f_Z(z)=1-{1\over2z}, z\gt1$$ $$E[\theta]=E[\arctan Z]=\int_{0}^{1}\arctan(z)\times{z\over2}dz+\int_{1}^{\infty}\arctan(z)\times(1-{1\over2z})dz$$ But I don't know how to calculate $$\int_{1}^{\infty}\arctan(z)\times(1-{1\over2z})dz$$.
Am I doing correctly on this question? I also noticed that I didn't use the hint the question provides.

The problem is symmetric with respect to the line $$\theta = \pi/4$$. That is, for any point $$(x,y)$$ at $$\pi/4 + \Delta$$ there is a corresponding point at $$\pi/4 - \Delta$$. Hence: $${\cal E}(\theta) = \pi/4$$.
$${\cal E}(\theta) = \int\limits_{x=0}^1 \int\limits_{y=0}^1 \arctan (y/x)\ dx\ dy = \pi/4$$
• but the point is only inside the unit square.I think the domain of $\theta$ is from 0 to $\pi\over2$ – clement Oct 14 '18 at 22:58