TITLE: Evaluating $\int \frac{1}{2+3 \sin\left(x\right)}$
QUESTION [8 upvotes]: I'm helping my daughter on her calculus homework and it has been many years for me. The problem is
$$
\int \frac{1}{2+3 \sin\left(x\right)} dx
$$
From WolframAlpha, the substitution should be $u = \tan\frac{x}{2}$. Once you have the substitution, the solution is quite straightforward.
My question is how on earth do you come up with that substitution? Are there any rubrics/recipes? Or is it just intuition?

REPLY [4 votes]: Weierstrass Substitution, $z=\tan(x/2)$, works well in this kind of integral:
$$
\begin{align}
\sin(x)&=\frac{2z}{1+z^2}\\[6pt]
\cos(x)&=\frac{1-z^2}{1+z^2}\\[6pt]
\mathrm{d}x&=\frac{2\mathrm{d}z}{1+z^2}
\end{align}
$$
Then
$$
\begin{align}
\int\frac{\mathrm{d}x}{2+3\sin(x)}
&=\int\frac1{2+3\frac{2z}{1+z^2}}\frac{2\mathrm{d}z}{1+z^2}\\
&=\int\frac{\mathrm{d}z}{z^2+3z+1}\\
&=\int\frac{\mathrm{d}z}{(z+3/2)^2-5/4}\\
&=\frac1{\sqrt5}\int\left(\frac1{z+3/2-\sqrt{5/4}}-\frac1{z+3/2+\sqrt{5/4}}\right)\,\mathrm{d}z
\end{align}
$$
which is a simple form (thanks to Michael Hardy for pointing out partial fractions). Then back-substitute to get the answer in terms of $x$.