Solving $\displaystyle\int \frac{\ln(\tan(x))}{\sin^2(x)}dx$

Didn't get good notes on how to solve this problem so I wasn't able to solve it. The only thing I have to go off of is that a $$\frac{1}{\cos^2(x)}$$ was multiplied times it to give $$\dfrac{\ln(\tan(x))}{\sin^2(x)/\cos^2(x)}$$ but wasn't sure how this works. From that a substitution of $$u = \tan(x)$$ was used and from there its solvable. I was just unsure how we get the $$\frac{1}{\cos^2(x)}$$ seemingly for free? The final given answer was -1/tan(x)(ln(tan(x)-1/tan(x))+C. I'm not really looking for an answer, just an explanation of how my teacher did the problem

• $du = \sec^2(x) dx = \frac{1}{\cos^2(x)} dx$ Oct 22, 2019 at 2:56
• Gonzalo Benavides I was wondering how we add du for seemingly free even though its not in the original integral? Oct 22, 2019 at 3:07

Try integration by parts. Let $$u=\log(\tan x)$$ and $$dv=\csc^2 x\, dx$$. Then $$du=\csc x\sec x\, dx$$ and $$v=-\cot x$$. Thus, your integral turns into \begin{align} \int\frac{\log(\tan x)}{\sin^2 x}dx &= \int udv = uv-\int vdu \\ &= -\cot x\log(\tan x)+\int (-\csc^2 x)\, dx \\ &= -\cot x\, (\log(\tan x)+1)+c. \end{align}
$$\ln(\tan x)=-\ln(\cot x)$$
Now set $$\cot x=y,-\csc^2x\ dx=dy$$
You have to multiply both the numerator and denominator of the fraction by $$\frac{1}{cos^2 x}$$ to make sure it doesn't change. That gives $$\displaystyle\int \dfrac{\ln(\tan x)/\cos^2 x}{\sin^2 x/\cos^2 x}dx$$. Let $$u=\tan x$$. Then $$\dfrac{du}{dx}=\sec^2 xdx$$ so substitution gives $$\displaystyle\int \dfrac{\ln(\tan x)/\cos^2 x}{\sin^2 x/\cos^2 x}dx\\ =\displaystyle\int \dfrac{\ln(u)}{u^2}du\\ =-\frac{\ln u}{u}-\frac{1}{u}+C=-\frac{\ln \tan x}{\tan x}-\frac{1}{\tan x}\\ =-\cot x\cdot(\ln(\tan x)+1)+C$$.