Compute $\int \sin(x) \left( \frac{1}{\cos(x) + \sin(x)} + \frac{1}{\cos(x) - \sin(x)} \right)\,dx.$

I have this problem but I don't know how to continue.
Here it is: Compute $\int \sin(x) \left( \frac{1}{\cos(x) + \sin(x)} + \frac{1}{\cos(x) - \sin(x)} \right)\,dx.$
So I can anti differentiate the sin x to be cos x but I am unsure on where to go off that for the fraction. I don't want to multiply the fractions to create a big and messy function and I don't quite understate how to do partial fraction decomposition. I'm guessing I will have to do substitution?

Anyways, thank you for any help!


Multiplying the fractions is actually the way to go and everything cancels out! $$\int\sin x\left(\frac{2\cos x}{\cos^2x-\sin^2x}\right)dx = \int\frac{\sin 2x}{\cos 2x}dx = \int\tan 2x\; dx$$ Now, you just need to find the antiderivative of $\tan$.

By the way: partial fraction decomposition is only done for functions with polynomials as numerators and denominators. Unless you can make a genius substitution which transforms the integral to a rational function, partial fractions is irrelevant. Usually, when confronted with completely trigonometric integrals, the first thing you should try is to simplify the integrand using trigonometric identities; only then do you want to consider substitutions or integration by parts.


An alternate (but longer) solution:

Going back to the beginning - if we have simplified the original to $$\int\sin x\left(\frac{2\cos x}{\cos^2x-\sin^2x}\right)dx,$$ we can convert the denominator to $2 \cos^2 x - 1$ (as it's equivalent to $\cos^2x -\sin^2 x$) and use the substitution $$u = \cos x, du = -\sin x \ dx;$$ this would give us $$-\int \left(\frac{2u}{2u^2-1}\right)du.$$

Then we would do substitution again with $$v = 2u^2 - 1, dv = 4u \ du, \frac {1}{2} dv = 2u \ du$$ to get $$-\dfrac {1}{2} \int \left(\frac{dv}{v}\right)$$.

The integral above with respect to $v$ is $$-\dfrac {1}{2}\ln|v|+C;$$ now all we need to do is resubstitute $u$ and $x$ in succession giving us $$-\dfrac {1}{2}\ln|2u^2-1|+C+C_1 \Rightarrow --\dfrac {1}{2}\ln |(2(\cos x)^2-1)|+C+C_1+C_2.$$

Using the identity $$2 \cos^2 x -1 = \cos 2x$$ we arrive at $$\bbox[lightgray] {-\dfrac {1}{2} \ln |\cos 2x| + K}$$ where $K = C + C_1 + C_2$.

Side note: If we DID know the identity $2 \sin x \cos x = \sin 2x$, our substitution would be a slam dunk, i.e. $u = \cos 2x, du = -\dfrac {1}{2} \sin 2x \ dx,$ and we would get $-\dfrac {1}{2}$ $\int {du}/{u}$ immediately.