<s>[INST] Trigonometric substitution $\tan{\frac{x}{2}}=t$. What is $\cos{x}$ then? For example, the integral is:
$$\int \frac{\sin{x}}{3\sin{x}+4\cos{x}}dx$$
And we use the substitution: $\tan{\frac{x}{2}}=t$
Now, to get $\cos{x}$ in terms of $\tan\frac{x}{2}$, I first expressed $\cos^2\frac{x}{2}$ and $\sin^2\frac{x}{2}$ in temrs of $\tan\frac{x}{2}$:
$$\cos^2\frac{x}{2}=\frac{1}{\frac{1}{\cos^2\frac{x}{2}}}=\frac{1}{\frac{\sin^2\frac{x}{2}+\cos^2\frac{x}{2}}{\cos^2\frac{x}{2}}}=\frac{1}{1+\tan^2\frac{x}{2}}=\frac{1}{1+t^2}$$
$$\sin^2\frac{x}{2}=1-\cos^2\frac{x}{2}=1-\frac{1}{1+t^2}=\frac{t^2}{1+t^2}$$
Now, using trig idendity: $\cos{2x}=\cos^2{x}-\sin^2{x}$ we have:
$$\cos{x}=\bigg(\cos^2\frac{x}{2}-\sin^2\frac{x}{2}\bigg)=\frac{1}{1+t^2}-\frac{t^2}{1+t^2}=\frac{1-t^2}{1+t^2}$$
which is good, but, I don't know what is wrong with this next procedure (first, getting $\sin^2{x}$, then using trig identity $\sin^2{x}+\cos^2{x}=1$ getting $\cos{x}$).
So, first, expressing $\sin{x}$ in terms of $\tan\frac{x}{2}$ using trig identity $\sin{2x}=2\sin{x}\cos{x}$:
$$\sin^2{x}=4\sin^2\frac{x}{2}\cos^2\frac{x}{2}=4\cdot\frac{t^2}{1+t^2}\cdot\frac{1}{1+t^2}=\frac{4t^2}{(1+t^2)^2}$$
So:
$$\cos^2{x}=1-\sin^2{x}=1-\frac{4t^2}{(1+t^2)^2}=\frac{t^4-2t^2+1-4t^2}{(1+t^2)^2}=\frac{(t^2-1)^2}{(t^2+1)^2}$$
And, $\cos{x}$ is then:
$$\cos{x}=\pm\frac{t^2-1}{t^2+1}$$
Why do I get $\pm$ here? Did I make a mistake somewhere? Thank you for your time.
 [/INST] These are  well-known formulae :
$$\sin x =\frac{2t}{1+t^2},\qquad \cos x  =\frac{1-t^2}{1+t^2},\qquad \tan x =\frac{2t}{1-t^2}\quad(t\not\equiv\pm\frac\pi4\mod\pi).$$
A geometric proof of the formulae:
Consider the unit circle and a line passing through the point $(-1,0)$which has equation $y=t(x+1)$. Let $M$ be the second interection point of the line with the circle. If $x$ is the polar angle of $M$, we have $t=\tan \frac x 2$, and the coordinates of $M$ are $\;x_M=\cos x,\enspace y_M=\sin x$. Now the equation for the abscissae of the intersection points is
$$(1+t^2)x_M^2+2t^2x_M+t^2-1=0,$$
of which one of the roots is $-1$, hence the other root, by Viète's relations, is $x_M=-\dfrac{t^2-1}{t^2+1}$. You obtain also
$\;\sin x=y_M=t\biggl(\dfrac{1-t^2}{t^2+1}+1\biggr)=\dfrac{2t}{t^2+1}$.
That said, Bioche's rules stipulate  you should set $u=\tan x$. Indeed, $\mathrm d\mkern1mu x=\dfrac{\mathrm d\mkern1mu u}{1+u^2}$, hence
$$I=\int \frac{\sin{x}}{3\sin{x}+4\cos{x}}\mathrm d\mkern1mu x=\int\frac{u}{3+4u^2}\dfrac{\mathrm d\mkern1mu u}{1+u^2}.$$
Decomposing into partial fractions:
$$\frac u{(3+4u^2)(1+u^2)}=\frac{4u}{3+4u^2}-\frac{u}{1+u^2},$$
we get
\begin{align*}I&=\frac12\bigl(\ln(3+4u^2)-\ln(1+u^2)\bigr)\\&= \frac12\ln\biggl(\frac{3+4\tan^2x}{1+\tan^2x}\biggr)=\frac12\ln(4-\cos^2x).
\end{align*}
</s>