When I was trying to solve the integral $\int\frac{\sin x+\cos x}{\sqrt{1+\sin2x}}dx$ by using $(1+\sin2x)=(\sin x+\cos x)^2$, I obtained this integral $\int\frac{\sin x+\cos x}{|\sin x+\cos x|}dx$ where $|\cdot|$ is the absolute value function. If this problem were a definite integral then I would have simplified the denominator by removing the absolute value function. But here it's an indefinite integral. So, how to proceed further?
In my book, the integral $\int\frac{\sin x+\cos x}{\sqrt{1+\sin2x}}dx$ was solved by expressing the denominator of the integrand as $\sqrt{2-(\sin x-\cos x)^2}$ and then using the method of substitution $t=(\sin x-\cos x)$, $dt=(\sin x+\cos x)dx$ and so on. I totally understood this method but I'm interested in solving the integral $\int\frac{\sin x+\cos x}{|\sin x+\cos x|}dx$ to obtain the final result.
The final result obtained by the method outlined in the book is $\sin^{-1}\sin(x-\pi/4)+C$. It would be helpful if you could explain how to obtain this result by evaluating the integral in the question.