In my research, I recently came across the integral $$ I(a,b) = \int_{\theta_1}^{\theta_2} \frac{\sin^2 \theta}{(a \sin \theta - b \cos \theta)^2}\,\mathrm{d}\theta, $$ where the range of integration $[\theta_1, \theta_2]$ is defined slightly differently in the two cases I'm interested in:
- Case I: $[\theta_1, \theta_2] = \{ \theta \in [0, \pi]: a \sin \theta - b \cos \theta > 1 \}$
- Case II: $[\theta_1, \theta_2] = \{ \theta \in [0, \pi]: a \sin \theta - b \cos \theta > b \}$
The constants $a$ and $b$ are positive, but other than that they are arbitrary.
In the case $b = 1$, these two cases are the same, the lower bound of integration is $\theta_1 = 2 \tan^{-1} (1/a)$, the upper bound is $\theta_2 = \pi$, and the integral evaluates to $$ I(a,1) = \frac{a + (a^2 - 1) \tan^{-1} a}{(a^2 + 1)^2} $$ (thanks to Mathematica.)
However, I haven't been able to find nearly so nice an expression for the integrand in the cases where $b \neq 1$. The bounds of integration can be found by solving a quadratic equation for $\cos \theta$, but the expressions aren't "nice". Mathematica is little help, since it has trouble finding an antiderivative that works in both Quadrant I and Quadrant II. (It also throws imaginary numbers into the results; they cancel out when you simplify the resulting expressions, but are rather unsightly all the same.)
If all else fails, I can numerically integrate this; but I'm wondering if there are any slick mathematical substitutions I can use to make my life easier.
The substitution $t = \tan \theta$ was awkward in this case, since the angles being integrated over were in both Quadrants I and II ($\theta \in [0, \pi]$), and so would have required splitting the range. Instead, a substitution $u = \cot \theta$ (note that $\cot \theta$ is continuous over $[0,\pi]$) turned out to be effective: $$ I(a,b) = \int_{\theta_1}^{\theta_2} \frac{\mathrm{d}\theta}{(a - b \cot \theta)^2} = - \int_{u_1}^{u_2} \frac{\mathrm{d}u}{(1 + u^2)(a - b u)^2}$$ The integrand can then be expanded in partial fractions: $$ \frac{1}{(1+u^2)(a - bu)^2} = \frac{1}{(a^2 + b^2)^2} \left[\frac{b^2(a^2 + b^2)}{(a - bu)^2} + \frac{2 a b^2}{a - bu} + \frac{a^2 - b^2 + 2 a b u}{1 + u^2} \right] $$ These individual terms can then be integrated using standard techniques.