Thank you for reading!
I want to calculate the area as follows.
$$
z > 0,
x^2 + y^2 + z^2 = r^2 ,
\left|\frac{x}{\sqrt{x^2+y^2+z^2}}\right| < \frac{\sqrt{2}}{2} ,
\left|\frac{y}{\sqrt{x^2+y^2+z^2}}\right| < \frac{\sqrt{2}}{2}
$$
And I generate the figure from Mathematica:

The calculation result from Mathematica is:
In[91]:= A = ImplicitRegion[z > 0 && x^2 + y^2 + z^2 == r^2 &&
Abs[x/Sqrt[x^2 + y^2 + z^2]] < Sqrt[2]/2 && Abs[y/Sqrt[x^2 + y^2 + z^2]] < Sqrt[2]/2, {x, y, z}];
Assuming[r>0,Underscript[\[Integral], {x,y,z}\[Element]A]1]
Out[92]= 2 (-1+Sqrt[2]) \[Pi] r^2
$$2 \left(\sqrt{2}-1\right) \pi r^2$$ Here is what I tried:
- Assume the angel between the surface element and xz plane is $\theta_1$ and the angle between the surface element and yz plane is $\theta_2$, then the area can be represented by $(R,\theta_1,\theta_2)$: $$R=r,-\pi/4<\theta_1<\pi/4,-\pi/4<\theta_2<\pi/4$$ Then the surface element would be: $$rd\theta_1rd\theta_2$$ The area would be: $$\int_{-\pi/4}^{\pi/4}\int_{-\pi/4}^{\pi/4}rd\theta_1rd\theta_2=\frac{\pi^2}{4}r^2$$ which is wrong.
- The area of region $$ x^2 + y^2 + z^2 = r^2 , \left|\frac{x}{\sqrt{x^2+y^2+z^2}}\right| < \frac{\sqrt{2}}{2} , \left|\frac{y}{\sqrt{x^2+y^2+z^2}}\right| < \frac{\sqrt{2}}{2} $$ is twice bigger as shown below:
Clearly, the area is: $$4\pi r^2-4\times[2\pi r^2(1-\frac{\sqrt{2}}{2})]=4\sqrt{2}\pi r^2-4\pi r^2$$ which is just twice the right answer as we expected. To explain it more, the area we want is the total sphere area minus these four blank regions as shown in the figure.
However, when the range of $\theta_1$ and $\theta_2$ is not $[-\pi/4,\pi/4]$, the result wouldn't be got from method 2. In fact, method 1 is more suitable for arbitraty angle range.
Could you help me to calculate the right integration result for arbitrary angle range? Any help is appreciated!

In spherical coordinates, parameterize one quadrant of the surface by
$$\vec s(u,v) = \langle r \cos u \sin v, r \sin u \sin v, r \cos v \rangle .$$
Letting the azimuthal angle $u\in\left[-\dfrac\pi4,\dfrac\pi4\right]$ vary in a quadrant of the $(u,v)$ plane, we can extract a one-to-one variable upper bound for the polar angle $v$ with the help of the appropriate cone that truncates the sphere. In this quadrant,
$$\frac x{\sqrt{x^2+y^2+z^2}} = \frac{\sqrt2}2 \implies \frac{r \cos u \sin v}{\sqrt{r^2}} = \frac1{\sqrt2} \implies v = \sin^{-1}\left(\frac{\sec u}{\sqrt2}\right).$$
Here's a visualization in Mathematica with $r=1$ (code below). The golden portion corresponds to our parameterization.
By symmetry, the total area of the surface is
$$\begin{align*} & 4 \int_{-\tfrac\pi4}^{\tfrac\pi4} \int_0^{\sin^{-1}\left(\tfrac{\sec u}{\sqrt2}\right)} \left\|\frac{\partial \vec s}{\partial u} \times \frac{\partial \vec s}{\partial v}\right\| \, dv \, du \\ & = 4 r^2 \int_{-\tfrac\pi4}^{\tfrac\pi4} \int_0^{\sin^{-1}\left(\tfrac{\sec u}{\sqrt2}\right)} \sin v \, dv \, du \\ &= 4r^2 \int_{-\tfrac\pi4}^{\tfrac\pi4} \left(1-\cos\left(\sin^{-1}\left(\frac{\sec u}{\sqrt2}\right)\right)\right) \, du \\ &= 2\pi r^2 - 4\sqrt2\,r^2 \int_0^{\tfrac\pi4} \sqrt{1-\tan^2u} \, du \\ \end{align*}$$
One way to compute the remaining integral is to substitute
$$\tan u = \frac{1-w^2}{1+w^2} \implies du = -\frac{2w}{1+w^4} \, dw$$
so that
$$\begin{align*} & \int_0^{\tfrac\pi4} \sqrt{1-\tan^2u} \, du \\ &= \int_0^1 \sqrt{1-\frac{(1-w^2)^2}{(1+w^2)^2}} \, \frac{2w\,dw}{1+w^4} \\ &= \int_0^1 \frac{4w^2}{\left(1+w^2\right) \left(1+w^4\right)} \, dw \\ &= \int_0^1 \left(\frac2{\left(\sqrt2\,w-1\right)^2+1} + \frac{2}{\left(\sqrt2\,w+1\right)^2+1} - \frac2{1+w^2}\right) \, dw = \frac{\sqrt2-1}2\pi \end{align*}$$
which makes the total area $\boxed{2(\sqrt2-1)\pi r^2}$, as expected.