<s>[INST] finding integral of $ \int \frac{1}{\sin x + \sqrt{3} \cos x}\ dx $ In $ \int\frac{1}{\sin x + \sqrt{3} \cos x}\ dx $, If I multiply and divide by $1/2$ I get $$ \int\frac{1/2}{\frac{1}{2} \sin x + \frac{\sqrt{3}}{2} \cos x}\ dx ,$$
then I can write $ 1/2=\sin (\frac{\pi}{6}) $ and $ \sqrt{3}/2=\cos (\frac{\pi}{6}) $ and apply $\cos(a-b)=\cos a \cos b + \sin a \sin b$,
I'll get $ \int\frac{1}{\cos(\frac{\pi}{6} - x)}\ dx $, I get $ \int \sec(\frac{\pi}{6} - x)\ dx $, now we know $ \int \sec(x)\ dx = \log|\tan(\frac{\pi}{4}+\frac{x}{2})| + c $ ,
so I finally get $$ \int\frac{1}{\sin x + \sqrt{3} \cos x}\ dx = \frac{1}{2}\log|\tan(\frac{\pi}{4}+\frac{\pi}{6}-\frac{x}{2})| + c $$
However if at this step $ \int\frac{1/2}{\frac{1}{2} \sin x + \frac{\sqrt{3}}{2} \cos x}\ dx $
I take $ 1/2=\cos (\frac{\pi}{3}) $ and $ \sqrt{3}/2=\sin (\frac{\pi}{3})$, then what I get is $ \int\frac{1}{\sin(\frac{\pi}{3} + x)}\ dx $, which is equal to $ \int \csc(\frac{\pi}{3} + x)\ dx $, now we know $ \int \csc(x)\ dx = \log|\tan(\frac{x}{2})| + c $
so I finally get $$ \int\frac{1}{\sin x + \sqrt{3} \cos x}\ dx = \frac{1}{2}\log|\tan(\frac{\pi}{6}+\frac{x}{2})| + c $$
why answer is different, I have rechecked and could not find any mistake
 [/INST] You should not get different answers (up to a constant of integration.) In fact, this is simply a matter of a calculation error.
$$\int \sec x\, \mathrm dx = \log\left|\tan\left(\frac\pi 4 + \frac x2 \right) \right| + C$$
gives
$$\frac12 \int \sec \left(x - \frac\pi 6 \right)\mathrm dx = \frac12 \log\left|\tan\left(\frac\pi 6 + \frac x2 \right) \right| + C$$
as $\frac\pi 4 + \frac x 2 - \frac {\pi}{12} = \frac x 2 + \frac \pi 6$. On the other hand,
$$\int \operatorname{cosec} x\, \mathrm dx = \log\left|\tan\left(\frac x2 \right) \right| + C$$
gives
$$\frac12 \int \operatorname{cosec}\left(x + \frac\pi 3 \right) \, \mathrm dx = \frac12 \log\left|\tan\left(\frac\pi 6 + \frac x2 \right) \right| + C$$
as $\frac12 \left( x + \frac\pi 3\right) = \frac x2 + \frac \pi 6$.
</s>