# Quick question regarding $\int \frac{\cos x + \sin x}{\sin 2x}\,dx$

I already asked a question here regarding the discrepancy between the answers I get when I work integrals by hand and the result I can verify using $Mathematica$. I only know enough about $Mathematica$ to type in the commands I need to verify results, plot graphs of polynomials, etc.

Usually I get to the same answer that the program produces, which I always find a bit gratifying, but other times I get results that are equivalent but quite different and often tedious to transfer for one form to the other to verify the equivalence.

Anyway, since this happens to me quite often lately, I wonder how I could check whether I am getting correct results in a reliable way.

For example $$\int \frac{\cos x + \sin x}{\sin 2x}\,dx$$ I use the identity $\sin 2x = 2 \sin x \cos x$ and get $$\frac 12 \int \frac {\cos x + \sin x}{\sin x \cos x}\, dx$$

$$=\, \frac 12 \int \frac {\cos x}{\sin x \cos x}+\frac {\sin x}{\sin x \cos x}\, dx$$

$$=\, \frac 12 \int \csc x \, dx \; + \; \frac 12 \int \sec x \,dx$$

$$=\, -\frac 12 \ln {|\csc x + \cot x|} + \frac 12 \ln {|\sec x + \tan x|}+C$$

This is not the same as the result from $Mathematica$, which gives $$-\frac 12 \ln \left(\cos \frac x2 \right) - \frac 12 \ln \left( \cos \frac x2 - \sin \frac x2 \right)+ \frac 12 \ln \left( \sin \frac x2 \right) + \ln \left( \cos \frac x2 + \sin\frac x2 \right)$$ is this equivalent to my result $$=\, -\frac 12 \ln {|\csc x + \cot x|} + \frac 12 \ln {|\sec x + \tan x|}+C$$ and how could I reliably verify my answers with $Mathematica$?

• What is the Mathematica result? It may be possible to show both are equivalent. – Mike Feb 11 '17 at 21:49
• you could numerically compare results for a definite integral e.g. from $\frac\pi 4$ to $\frac\pi 3$ – WW1 Feb 11 '17 at 21:49
• Give Mathematica the integral minus the result you think ... Mathematica should be smart enough to workout they are the same & give you back the result zero ! – Donald Splutterwit Feb 11 '17 at 21:54
• @Mike I added it to my question and doing so it seems to me that some identity has to be involved here. – user409521 Feb 11 '17 at 21:59
• You can probably verify they differ by a constant; just try computing the derivative of the difference of the two functions. If it's zero, you should be alright. – Lonidard Feb 11 '17 at 22:27

It's the same result, if you change the parentheses for modulus:

$$-\ln \left| \cos \frac x2 - \sin \frac x2 \right|+ \ln \left| \sin \frac x2 + \cos \frac x2 \right| = \ln \frac{\left| \sin \frac x2 + \cos \frac x2 \right|}{\left| \cos \frac x2 - \sin \frac x2 \right|} =$$

$$\ln \left| \frac{\left( \sin \frac x2 + \cos \frac x2 \right)^2}{\left( \cos \frac x2 - \sin \frac x2 \right)\left( \sin \frac x2 + \cos \frac x2 \right)} \right | = \ln \left| \frac{1 + \sin x}{\cos x} \right | = \ln |\sec x + \tan x|$$

And

$$-\ln {|\csc x + \cot x|} = \ln \left|\frac{\sin x}{1+\cos x} \right| = \ln \left|\frac{2\sin \frac x2\cos \frac x2}{2\cos^2 \frac x2} \right| = \ln \left |\tan \frac x2 \right| = \ln \left | \sin \frac x2 \right| - \ln \left |\cos \frac x2 \right|$$

• Please rectify the last part – lab bhattacharjee Feb 12 '17 at 6:59
• @labbhattacharjee thanks! – Rafael Deiga Feb 12 '17 at 16:34

Check your integrals by taking the derivatives; if you're good at derivatives it's easy. Faster and more productive than Mathematica in a large number of cases.