Calculate $\iint\frac{dxdy}{(1+x^2+y^2)^2}$ over a triangle 
Calculate
$$\iint\frac{dxdy}{(1+x^2+y^2)^2}$$ over the triangle $(0,0)$, $(2,0)$, $(1,\sqrt{3})$.    

So I tried changing to polar coordinates and I know that the angle is between $0$ and $\frac{\pi}{3}$ but I couldn't figure how to set the radius because it depends on the angle.
 A: Yes, using polar coordinates is a good idea. We find
$$\iint_T\frac{dxdy}{(1+x^2+y^2)^2}=\int_{\theta=0}^{\pi/3}d\theta\int_{\rho=0}^{f(\theta)}\frac{\rho d\rho}{(1+\rho^2)^2}
=-\frac{1}{2}\int_{\theta=0}^{\pi/3}\left[\frac{1}{1+\rho^2 }\right]_{\rho=0}^{f(\theta)}\,d\theta$$
where the upperbound $\rho=f(\theta)$ can be obtained from the line joining the points $(1,\sqrt{3})$ and $(2,0)$,
$$\rho\sin(\theta)=y=\sqrt{3}(2-x)=\sqrt{3}(2-\rho\cos(\theta))$$
and therefore
$$\rho=f(\theta)=\frac{2\sqrt{3}}{\sin(\theta)+\sqrt{3}\cos(\theta)}
=\frac{\sqrt{3}}{\sin(\theta+\pi/3)}.$$
Can you take it from here?
A: As you wrote, $\theta$ can take any value from $0$ to $\frac\pi3$. For each such $\theta$, $\rho$ can take any value from $0$ to $r$, where $r$ is such that $(r\cos\theta,r\sin\theta)$ belongs to the segment joining $(2,0)$ to $\left(1\,\sqrt3\right)$. This segment is part of the line $y=2\sqrt3-\sqrt3x$. So, you solve the equation$$r\sin\theta=2\sqrt3-\sqrt3r\cos\theta$$and you will get that$$r=\frac{\sqrt3}{\sin\left(\theta+\frac\pi3\right)}.$$So, your integral is equal to$$\int_0^{\pi/3}\int_0^{\sqrt3/\sin\left(\theta+\pi/3\right)}\frac\rho{(1+\rho^2)^2}\,\mathrm d\rho\,\mathrm d\theta.$$
A: Here is an alternative to Robert's nice way to find how $r(\theta)$ depends on $\theta$.
Let $A(0,0)$, $B(2,0)$ and $C(1,\sqrt{3})$ be the three vertices of the triangle. Imagin, or see the picture below, a ray starting from $A$ and intersects with the side $CB$ at $D$. Suppose the angle $\angle DAB=\theta$. You want to find the length of $AD$ in terms of $\theta$. You can apply the law of sines here to the triangle $ABD$:
$$
\frac{\sin(\pi-\theta-\pi/3)}{2}=\frac{\sin (\pi/3)}{f(\theta)},
$$
Since $\sin(\pi-a)=\sin(a)$, and $\sin(\pi/2) = \sqrt{3}/2$, it follows that
$$
f(\theta) = \frac{\sqrt{3}}{\sin(\theta+\pi/3)}\;.
$$
Let us continue the calculations that are done in Robert's answer:
$$\iint_T\frac{dxdy}{(1+x^2+y^2)^2}
=\int_{0}^{\pi/3}\left(\int_{0}^{f(\theta)}\frac{\rho d\rho}{(1+\rho^2)^2}\right)\;d\theta
=-\frac{1}{2}\int_{0}^{\pi/3}
\left[
\frac{1}{1+\rho^2 }
\right]_{\rho=0}^{\rho=f(\theta)}\,d\theta=:\frac12 I\;.
$$
where
$$
I=-\int_{0}^{\pi/3}
\frac{1}{1+f^2(\theta) }-1\,d\theta
=\int_{0}^{\pi/3}
\frac{f^2(\theta)}{1+f^2(\theta) }\,d\theta
=\int_{0}^{\pi/3}\frac{3}{3+\sin^2(\theta+\pi/3)}\;d\theta=:3J\;.
$$
Up to this point, you can go directly to the general method of Weierstrass substitution. But in this specific case, some trig substitutions makes the integral easier. 
Observe that $\cos(\pi/2-a)=\sin(a)$. So
$$
\begin{align}
J &= \int_{0}^{\pi / 3} \frac{1}{\cos ^{2}\left(\frac{\pi}{6}-x\right)+3} dx
= \int_{-\pi / 6}^{\pi / 6} \frac{1}{\cos ^{2}(u)+3} du
= \int_{-\pi / 6}^{\pi / 6} \frac{\sec ^{2}(u)}{3 \sec ^{2}(u)+1} du\\
&= \int_{-\pi / 6}^{\pi / 6} \frac{\sec ^{2}(u)}{3 \tan ^{2}(u)+4} du
\quad (\sec^2u = \tan^2u+1)\\
&= \int_{-1 / \sqrt{3}}^{1 / \sqrt{3}} \frac{1}{3 s^{2}+4} ds
\quad (d(\tan u)=\sec^2u\;du)\\
&= \frac{1}{4} \int_{-1 / \sqrt{3}}^{1 / \sqrt{3}} \frac{1}{\frac{3 s^{2}}{4}+1} ds
 =\frac{\sqrt{3}}{6} \int_{-1 / 2}^{1 / 2} \frac{1}{p^{2}+1} d p\\
&=\frac{\sqrt{3}}{3} \tan ^{-1}\left(\frac{1}{2}\right)
= \frac{\sqrt{3}}{3} \cot ^{-1}(2)\;.
\end{align}
$$
So the result is
$$
\frac32J = \frac{\sqrt{3}}{2} \cot ^{-1}(2)\;.
$$

A: Let us have a solution based on an alternative idea. We consider on the triangle $T$ the one-form
$$
\omega=\frac 12\cdot \frac {x\; dy - y\; dx}{1+x^2+y^2}\ .
$$
Then 
$$
\begin{aligned}
2d\omega
&=
\frac\partial{\partial x}\left(\frac x{1+x^2+y^2}\right)
dx\wedge dy
+
\frac\partial{\partial x}\left(\frac {-y}{1+x^2+y^2}\right)
dy\wedge dx
\\
&=\frac 2{(1+x^2+y^2)^2}\; dx\wedge dy\ .
\end{aligned}
$$
We apply Stokes now. We parametrize the boundary of $T$ using the maps 


*

*$t\to(t,0)$ for $t$ from $0$ to $2$, and there will be no contribution because of $y=0$,

*$t\to(2-t,t\sqrt 3)$ for $t$ from $0$ to $1$,

*$t\to(t,t\sqrt 3)$ for $t$ from $1$ to $0$, and there will be no contribution, because $x\; dy-y\; dx$ becomes $t\;(t\sqrt 3)'\; dt -(t\sqrt 3)\; t'\; dt$,


and compute explicitly:
$$
\begin{aligned}
&\int_{\partial T}
\frac {x\;dy}{1+x^2+y^2}
=
\int_0^2\frac {t\cdot 0'\; dt}{1+t^2+0^2}
\\
&\qquad\qquad\qquad
+
\int_0^1\frac {(2-t)\; (t\sqrt 3)'\; dt}{1+(2-t)^2+3t^2}
+
\int_1^0\frac {t\; (t\sqrt 3)'\; dt}{1+t^2+3t^2}
\ ,
\\[3mm]
&\int_{\partial T}
\frac {y\;dx}{1+x^2+y^2}
=
\int_0^2\frac {0\cdot t'\; dt}{1+t^2+0^2}
\\
&\qquad\qquad\qquad
+
\int_0^1\frac {t\sqrt 3\; (2-t)'\; dt}{1+(2-t)^2+3t^2}
+
\int_1^0\frac {t\sqrt 3\; t'\; dt}{1+t^2+3t^2}
\ ,
\\[3mm]
&\iint_T\frac {dx\; dy}{(1+x^2+y^2)^2}=
\iint_T d\omega
\\
&\qquad=
\int_{\partial T} \omega
\\
&\qquad
=\frac 12\int_0^1
\frac {(2-t)\cdot(t\sqrt 3)'-(t\sqrt 3)\; (2-t)'}{1+(2-t)^2+3t^2}
\; dt
\\
&\qquad=\frac {\sqrt 3}2\int_0^1
\frac {(2-t)+t}{(2t-1)^2+2^2}
\; dt
=\color{blue}{\frac {\sqrt 3}2\arctan\frac 12}\ .
\end{aligned}
$$
(Note: All details are included for didactical reasons, now please remove all details to have a two lines computation, given the formula for $d\omega$ and the cancellations on the first and third line path parametrizing $\partial T$.) 

A sage numerical check using Fubini...
sage: var('x,y');
sage: f = 1 / (1 + x^2 + y^2)^2
sage: assume(x>0)
sage: assume(x<2)
sage: J1 = integral( integral(f, y, 0,    x *sqrt(3)), x, 0, 1)
sage: J2 = integral( integral(f, y, 0, (2-x)*sqrt(3)), x, 1, 2)

sage: (J1+J2).n()
0.401530607798613
sage: ( sqrt(3)/2*atan(1/2) ).n()
0.401530607798613

