A tricky integration over the unit sphere

I am going to write $\theta_0$ where you write $\theta$ so that I can later use $\theta$ in the usual way as part of spherical coordinates.

Define vectors $\mathbf u_1 = (1, 0, 0)^T$ and $\mathbf u_2 = (\cos\theta_0, \sin\theta_0, 0)^T$. For any point $(x,y,z)$, if we view that point as a vector $\mathbf v = (x,y,z)^T$ then $x = \mathbf v^T\mathbf u_1$ and $x\cos\theta + y\sin\theta = \mathbf v^T\mathbf u_2.$

The angle between the vectors $\mathbf u_1$ and $\mathbf u_2$ is $\theta_0.$ Let $S$ be the plane through the $z$ axis bisecting the angle between $\mathbf u_1$ and $\mathbf u_2$; then $\max\{0,x,x\cos\theta_0+y\sin\theta_0\} = x$ when $(x,y,z)$ is on the same side of the $y,z$ plane as $\mathbf u_1$ (or the positive $x$ axis) and also on the same side of the plane $P$ as $\mathbf u_1$. That is, the part of the integral where we are just integrating $x$ is a segment of the sphere generated by placing a semicircle with endpoints at $(0,0,\pm 1)$ and rotating it from the $y,z$ plane to the $x,z$ plane and an angle $\frac{\theta_0}2$ beyond that. That is, the angle of the segment is $\frac\pi2 + \frac{\theta_0}2.$

On another segment of the sphere we integrate $x\cos\theta_0+y\sin\theta_0.$ That segment is a mirror image of the first segment in the plane $P,$ and its contribution to the integral is the same. On the remainder of the sphere the integral is zero.

So we just have to integrate $x$ over the segment on which the integrand is $x,$ and then multiply the result by $2$ in order to count both of the segments where the integral is non-zero.

Depending on which way $\mathbf u_2$ is pointing, the segment where we integrate $x$ might be mostly on the positive $y$ side of the $x,z$ plane or mostly on the negative $y$ side. Either way we get the same integral by reflection through the $x,z$ plane, so we can get the correct answer by assuming the segment is mostly on the positive $y$ side.

So you just need to compute this integral for $r = 1$ in spherical coordinates (where $\phi = 0$ on the positive $z$ axis and $\theta = 0$ on the positive $x$ axis): $$ 2 \int_{-\theta_0/2}^{\pi/2} \int_0^\pi x \sin\phi\, \mathrm d\phi\,\mathrm d\theta = 2 \int_{-\theta_0/2}^{\pi/2} \int_0^\pi \cos\theta \sin^2\phi \,\mathrm d\phi\,\mathrm d\theta = \pi \left(1 + \sin \frac{\theta_0}2 \right),$$

which is exactly equal to your numeric result.


Forgive me, but I want to do this integral in polar coordinates, and for that I want to use the symbol $\theta$ that is your special number. I will write $\alpha \in (0,2\pi)$ for the number you pick. In polar coordinates,

$$x=\sin\theta\cos\phi, y=\sin \theta\sin\phi, z=\cos \theta$$

Let's simplify your integrand. We want to know which of three numbers is bigger: $0$, $\sin\theta\cos \phi$, and $x\cos\alpha + y\sin\alpha$. Substitution gives: $$x\cos\alpha + y\sin\alpha = \sin\theta \cos \phi \cos \alpha + \sin \theta \sin \phi\sin \alpha = \sin \theta \cos(\phi-\alpha)$$ Comparing our 2 functions with $0$ is easy enough, but comparing them with each other is hard. Consider:

\begin{align*} \cos \phi - \cos(\phi-\alpha) &= -2\sin\left(\frac{\phi -(\phi-\alpha)}{2}\right)\sin\left(\frac{\phi +(\phi - \alpha)}{2}\right)\\ &=2\sin\left(\frac{\alpha}{2}\right)\sin\left(\frac{\alpha}{2} - \phi\right) \end{align*} which is $0$ if either $\alpha/2=n\pi$ (obviously), or $\phi = \alpha/2 + n\pi$.

Of course, your integral will be zero if both $x$ and $x\cos\alpha + y\sin \alpha$ are negative. When does that happen? Well, $x < 0 $ iff $\cos \phi < 0$. And $\sin\theta \cos(\phi-\alpha) < 0$ iff $\cos(\phi-\alpha) < 0$ since the polar angle $\theta$ is in $(0,\pi)$. So both terms are negative when:

$$\pi/2 \le \phi \le 3\pi/2, \quad \text{and} \quad \phi \in (\alpha + \pi/2, \alpha-\pi/2) + 2\pi \mathbb{Z}$$

That should be enough to go on, I think.