TITLE: Calculate $\int_{0}^{\pi} \frac{x}{a-\sin{x}}dx , \quad a>1$
QUESTION [7 upvotes]: I have trouble calculating this integral.
I tried integration by parts and trigonometric function.
$$\int_{0}^{\pi} \frac{x}{a-\sin{x}}dx , \quad a>1$$

REPLY [2 votes]: General Case
In these types of definite integrals, never forget to use this general identity
$$I=\int_{a}^{b}f(x)dx=\int_{a}^{b}f(a+b-x)dx$$
Which can be proved by the substitution $x \to a+b-x$. Then one writes the definite integral as the average of the two expressions above to obtain
$$I=\int_{a}^{b} \frac{1}{2}[f(x)+f(a+b-x)]dx$$
Next, the magic happens since you can find the primitive of $g(x)=\frac{1}{2}[f(x)+f(a+b-x)]$ but not that of $f(x)$ or $f(a+b-x)$. This is usually due to the simpler form of $g(x)$ in comparison with $f(x)$ or $f(a+b-x)$ as some expression has cancelled or disappeared in $g(x)$.

Your Example
In your example we have
$$\begin{align}
a &= 0 \\
b &= \pi \\
f(x) &= \frac{x}{a-\sin(x)} \\
f(a+b-x) &= \frac{\pi-x}{a-\sin(\pi-x)} = \frac{\pi-x}{a-\sin(x)} \\
g(x) &= \frac{\pi}{2} \frac{1}{a-\sin(x)}
\end{align}$$
Can you see the cancellation that is happening in $g(x)$? Then the integral becomes
$$I=\frac{\pi}{2}\int_{0}^{\pi} \frac{1}{a-\sin(x)} dx$$

Case $|a| \gt 1$

Then you can find by tangent half angle substitution $u=\tan(\frac{x}{2})$ that
$$F(x)=\int \frac{1}{a-\sin(x)} = \frac{2}{\sqrt{a^2-1}} \arctan\left(\frac{a \tan(\frac{x}{2})-1}{\sqrt{a^2-1}}\right) + C$$
As you can see this formula is valid for $|a| \gt 1$. Hence, the final result will be

$$I=\frac{\pi}{\sqrt{a^2-1}} \left(\arctan\left(\frac{1}{\sqrt{a^2-1}}\right)+\frac{\pi}{2}\right)$$


Case $|a| \lt 1$

I will leave this case as an exercise for you. The procedure is the same but just the $F(x)$ will be different. However, $F(x)$ is obtained with the same technique for substitution.

Case $|a|=1$

This is also another case, which should be handled separately. The $F(x)$ in this case is the simplest one and is obtained with the same techniques.