I tried to solve the integral $\int \frac{1}{\sqrt{1+\sin2x}}dx$ by using $1+\sin2x=(\sin x+\cos x)^2$ but got stuck. So I referred the solution in my book which is given below:

$$ I=\int \frac{1}{\sqrt{1+\sin2x}}dx $$ $$ = \int \frac{1}{\sqrt{1-\cos(\frac \pi 2+2x)}}dx\tag1\\ = \int \frac{1}{\sqrt{2\sin^2(\frac \pi 4+x)}}dx\\ =\frac 1 {\sqrt2} \int \csc\left(\frac \pi 4+x\right)dx\\ = \color{red}{\frac 1 {\sqrt2} \log\left|\tan\left(\frac \pi 8+\frac x 2\right)\right|+C}(*) $$

I wondered what if I replaced $\sin 2x$ by $\cos\left(\frac \pi 2 -2x\right)$ instead of $-\cos\left(\frac \pi 2 +2x\right)$ in step $(1)$. So I proceeded as follows:

$$ I=\int \frac{1}{\sqrt{1+\sin2x}}dx $$ $$ = \int \frac{1}{\sqrt{1+\cos(\frac \pi 2-2x)}}dx\\ = \int \frac{1}{\sqrt{2\cos^2(\frac \pi 4-x)}}dx\\ =\frac 1 {\sqrt2} \int \sec\left(\frac \pi 4-x\right)dx\\ = \color{red}{\frac 1 {\sqrt2} \log\left|\tan\left(\frac {3\pi} 8-\frac x 2\right)\right|+C}(**) $$

But I got a different result. Could you please explain the reason for this anomaly? Is it wrong to do a different replacement in step $(1)$? I think it shouldn't make any difference.

Further, could you please explain how to think we must be doing the replacement instead of using $1+\sin2x=(\sin x+\cos x)^2$ to solve this integral? I got this idea only after looking the solution.

*Using $\int \csc x dx=\log\left|\tan\left(x/2\right)\right|+C$

**Using $\int \sec x dx=\log\left|\tan\left(\frac \pi 4 +\frac x 2\right)\right|+C$

  • 1
    $\begingroup$ Are you sure that this is different ? $\endgroup$
    – user65203
    Dec 18, 2019 at 10:23
  • $\begingroup$ You might want to check signs, since $\frac 1 {\sqrt2} \log\left|\tan\left(\frac {3\pi} 8-\frac x 2\right)\right| = - \frac 1 {\sqrt2} \log\left|\tan\left(\frac \pi 8+\frac x 2\right)\right|$ $\endgroup$
    – Henry
    Dec 18, 2019 at 10:26
  • $\begingroup$ @YvesDaoust, I think yes. But it must be no. Is there anything wrong in my attempt? $\endgroup$
    – Vishnu
    Dec 18, 2019 at 10:31
  • $\begingroup$ @Henry, Could you please explain how you transformed the final solution obtained by me to the negative of the solution given in the book? Even then why is there a difference in the signs of the final expression? $\endgroup$
    – Vishnu
    Dec 18, 2019 at 10:33
  • $\begingroup$ My point is really that $\tan\left(\frac\pi 4+y\right)\, \tan\left(\frac\pi 4-y\right)=1$ so taking logarithms turns this into a sign change $\endgroup$
    – Henry
    Dec 18, 2019 at 10:38

1 Answer 1


I think I prefer your first idea for its cuteness. You're only a step away, for you have that $$\sin x+\cos x=\sqrt 2\sin\left(x+\fracπ4\right).$$

Then you would only want to do something which is a constant multiple of the form $$\int\csc y\mathrm dy,$$ which is a standard integral.

  • $\begingroup$ Thank you. You're right. I could have avoided this much trouble. If possible, could you please explain the reason for the inconsistency between the two methods used? $\endgroup$
    – Vishnu
    Dec 18, 2019 at 10:40
  • $\begingroup$ @M.GuruVishnu The problem is with the second method. What you have is a constant multiple of $$\int\sec\left(x-\fracπ4\right)\mathrm d\left(x-\fracπ4\right)=\log\left|\tan\left(\frac x2+\fracπ8\right)\right|+C,$$ as before. If you wanted to do it your way then you should have had $$\color{red}{-}\int\sec\left(\fracπ4-x\right)\mathrm d\left(\fracπ4-x\right)$$ instead (note the sign change). $\endgroup$
    – Allawonder
    Dec 18, 2019 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.