What's wrong in my calculation of $\int \frac{\sin x}{1 + \sin x} dx$?

I have the following function:

$$f: \bigg ( - \dfrac{\pi}{2}, \dfrac{\pi}{2} \bigg ) \rightarrow \mathbb{R} \hspace{2cm} f(x) = \dfrac{\sin x}{1 + \sin x}$$

And I have to find $$\displaystyle\int f(x) dx$$. This is what I did:

$$\int \dfrac{\sin x}{1 + \sin x}dx= \int \dfrac{1+ \sin x - 1}{1 + \sin x}dx = \int dx - \int \dfrac{1}{1 + \sin x}dx =$$ $$= x - \int \dfrac{1 - \sin x}{(1 + \sin x)(1 - \sin x)} dx$$

$$= x - \int \dfrac{1 - \sin x}{1 - \sin ^2 x} dx$$

$$= x - \int \dfrac{1 - \sin x}{\cos^2 x} dx$$

$$= x - \int \dfrac{1}{\cos^2x}dx + \int \dfrac{\sin x}{\cos^2 x}dx$$

$$= x - \tan x + \int \dfrac{\sin x}{\cos^2 x}dx$$

Let $$u = \cos x$$

$$du = - \sin x dx$$

$$=x - \tan x - \int \dfrac{1}{u^2}du$$

$$= x - \tan x + \dfrac{1}{u} + C$$

$$= x - \tan x + \dfrac{1}{\cos x} + C$$

The problem is that the options given in my textbook are the following:

A. $$x + \tan {\dfrac{x}{2}} + C$$

B. $$\dfrac{1}{1 + \tan{\frac{x}{2}}} + C$$

C. $$x + 2\tan{\dfrac{x}{2}} + C$$

D. $$\dfrac{2}{1 + \tan{\frac{x}{2}}} + C$$

E. $$x + \dfrac{2}{1 + \tan{\frac{x}{2}}} + C$$

None of them are the answer I got solving this integral. What is the mistake that I made and how can I find the right answer? By what I've been reading online, you can get different answers by solving an integral in different ways and all of them are considered correct. They differ by the constant $$C$$. I understand that, but I don't see how to solve this integral in such a way to get an answer among the given $$5$$. And, even more importantly, how can I recognize the right answer in exam conditions if the answer provided by my solution is not present among the given options? Is solving in a different manner my only hope?

• This is one of the faults of multiple choice questions. In this case they expected you to use the substitution $t=\tan\left(\frac{x}{2}\right)$. Your answer will be equivalent to one of the choices. – John Wayland Bales Dec 21 '19 at 0:57
• If you encounter this on exam, then you should be able to convert your answer into one of the ones they give you, by possibly adding a constant and applying trig identities. – Robo300 Dec 21 '19 at 1:02
• A deeper fault of multiple-choice for a question like that is that one could just differentiate the proposed answers and check the result at 0. Correct answer (E), but not proving that the student mastered the underlying concept or technique. – Catalin Zara Dec 21 '19 at 1:39
• @CatalinZara true ....... – Aryadeva Dec 21 '19 at 2:46

Required answer is $$E$$. Observe that $$\frac{1}{\cos x}-\tan x=\frac{1-\sin x}{\cos x}$$ $$=\frac{(\cos\frac{x}{2}-\sin\frac{x}{2})^2}{\cos^2\frac{x}{2}-\sin^2\frac{x}{2}}$$ $$=\frac{\cos\frac{x}{2}-\sin\frac{x}{2}}{\cos\frac{x}{2}+\sin\frac{x}{2}}$$ $$=\frac{1-\tan\frac{x}{2}}{1+\tan\frac{x}{2}}$$ $$=\frac{2}{1+\tan\frac{x}{2}}-1$$ Also, note that you could have directly got this answer if you have integrated $$\frac{1}{1+\sin x}$$ in a different manner, as follows. $$\int\frac{1}{1+\sin x}dx=\int\frac{1}{(\cos\frac{x}{2}+\sin\frac{x}{2})^2}dx$$ $$=\int \frac{1}{\cos^2\frac{x}{2}(1+\tan\frac{x}{2})^2}dx$$ Now substitute $$\tan\frac{x}{2}$$ and you are done.

• How did you get to $\dfrac{2}{1+\tan{\frac{x}{2}}}-1$ from $\dfrac{1-\tan {\frac{x}{2}}}{1+ \tan {\frac{x}{2}}}$? I didn't understand that bit. – user592938 Dec 22 '19 at 1:06
• @user2502, $\frac{1-\tan\frac{x}{2}}{1+\tan\frac{x}{2}}=\frac{2-(1+\tan\frac{x}{2})}{1+\tan\frac{x}{2}} = \frac{2}{1+\tan\frac{x}{2}}-1$ – Martund Dec 22 '19 at 6:28

Your answer is correct and it matches with choice (E). You have to use half angle formulas: $$\sin A = \frac{2 \tan \frac{A}{2}}{1+\tan^2 \frac{A}{2}} \quad \cos A = \frac{1-\tan^2 \frac{A}{2}}{1+\tan^2 \frac{A}{2}}$$ Observe that \begin{align*} \frac{1}{\cos x}-\tan x&=\frac{1-\sin x}{\cos x}\\ & = \frac{\left(1-\tan \frac{x}{2}\right)^2}{1-\tan^2 \frac{x}{2}}\\ & = \frac{1-\tan \frac{x}{2}}{1+\tan \frac{x}{2}}\\ & = 1+\frac{2}{1+\tan \frac{x}{2}}\\ \end{align*}

• How did you to the last line from your second to last line? I didn't understand that final bit. – user592938 Dec 21 '19 at 22:49

Beside verifying your answer is equivalent to one of the listed results, you may also integrate in $$\tan\frac x2$$ since all the choices are in terms of it.

So, use $$\sin x =\frac{2\tan\frac x2}{1+\tan^2\frac x2}$$ to integrate,

$$\int \dfrac{1}{1 + \sin x}dx = \int \dfrac{1}{1 + \frac{2\tan\frac x2}{1+\tan^2\frac x2}}dx =\int \dfrac{1+\tan^2\frac x2}{1+\tan^2\frac x2 + 2\tan\frac x2}dx$$ $$=\int \dfrac{\sec^2\frac x2}{(1+\tan\frac x2)^2} =\int \dfrac{2d(\tan\frac x2)}{(1+\tan\frac x2)^2} =-\dfrac{2}{1+\tan\frac x2}$$