<s>[INST] How do I go about solving this? I have tried substitution, but it is not working for me.
$$
\int_0^\pi \frac{dx}{\sqrt{(n^2+1)}+\sin(x)+n\cos(x)}=\int_0^\pi \frac{n dx}{\sqrt{(n^2+1)}+n\sin(x)+\cos(x)}=2
$$
General form of this integral is
$$
\int_0^\pi \frac{dx}{\sqrt{(n^2+m^2)}+m\sin(x)+n\cos(x)}=\frac{2}{m}
$$
 [/INST] First of all:
$$
(\sqrt{n^2+1}+\sin x+n\cos x)(\sqrt{n^2+1}-\sin x-n\cos x)=$$
$$
=n^2+1-n^2\cos^2x-2n\cos x\sin x-\sin^2 x=
$$
$$
=\cos^2x-2n\cos x\sin x+n^2\sin^2 x=(n\sin x-\cos x)^2
$$
So:
$$
\int\frac{\mathrm{d}x}{\sqrt{n^2+1}+\sin x+n\cos x}=\int\frac{(\sqrt{n^2+1}-\sin x-n\cos x)\mathrm{d}x}{(n\sin x-\cos x)^2}
$$
Now use the formula:
$$
\theta=\arctan\frac{b}{a}\qquad a\cos x+b\sin x=\sqrt{a^2+b^2}{\cos(x+\theta)}
$$
To finish this up.
Result:
$$
\int\frac{\mathrm{d}x}{\sqrt{n^2+1}+\sin x+n\cos x}=\frac{1-\sqrt{n^2+1} \sin (x)}{n \sin (x)-\cos (x)}$$
$$\int\frac{n\mathrm{d}x}{\sqrt{n^2+1}+n\sin x+\cos x}=\frac{\sqrt{n^2+1} \sin (x)-n}{n \cos (x)-\sin (x)}$$
</s>