How to evaluate $\int_{-\frac{7\pi}8}^{-\frac{5\pi}8}\dfrac{\sin(x)}{\tan^2(x)}dx$

So I was once again bored, and decided to evaluate some integrals for fun. After a while, I decided to give myself a sort of difficult integral to evaluate, and came up with this:$$\int_{-\frac{7\pi}8}^{-\frac{5\pi}8}\dfrac{\sin(x)}{\tan^2(x)}dx$$which I thought that I might be able to evaluate. Here is my attempt at doing so:\begin{align}\int_{-\frac{7\pi}8}^{-\frac{5\pi}8}\dfrac{\sin(x)}{\tan^2(x)}dx&=\int_{-\frac{7\pi}8}^{-\frac{5\pi}8}\dfrac{\sin(x)}{\left(\dfrac{\sin(x)}{\cos(x)}\right)^2}dx\\&=\int_{-\frac{7\pi}8}^{-\frac{5\pi}8}\dfrac{\cos^2(x)}{\sin(x)}dx\\&=\int_{-\frac{7\pi}8}^{-\frac{5\pi}8}\cos(x)\cot(x)dx\end{align} I was actually having trouble finding the antiderivative the second time I evaluated the integral. (as I usually check my work that I did the first time when writing my questions here.) This might be because I accidentally lost the original work that I did while finding the antiderivative of $$\cos(x)\cot(x)$$ with respect to $$x$$, so I decided to look up how to integrate the aforementioned integral and found what I had gotten the first time from Bhaskara-III's answer on the question "Evaluate the integral $$\int\cot(x)\cos(x)dx$$"[$$1$$] The following quote is from that answer.

$$\int\cot x\cos xdx$$

$$=\cot x\int\cos xdx-\int\left(\frac d{dx}(\cot x)\int\cos xdx\right)dx$$

$$=\cot x\sin x-\int(-\csc^2x)\sin xdx$$

$$=\cos x+\int\csc xdx$$

$$=\cos x+\ln(\csc x-\cot x)+C$$

Note we can simplify the inside of what should be a complex-valued logarithm to $$\csc(x)-\cot(x)=\tan\left(\dfrac x2\right)$$ and we can also get rid of the $$+C$$ because we are evaluating an area from point A to point B, so what we have now is$$\left[\cos(x)+\operatorname{Ln}\left(\tan\left(\dfrac x2\right)\right)\right]_{-\frac{7\pi}8}^{-\frac{5\pi}8}=\operatorname{Ln}\left(\dfrac{\tan\left(\dfrac{5\pi}{16}\right)}{\tan\left(\dfrac{7\pi}{16}\right)}\right)+\cos\left(\dfrac{5\pi}8\right)-\cos\left(\dfrac{7\pi}8\right)$$since $$\tan(x)$$ is an odd function except for odd multiples of $$\dfrac\pi2$$ (meaning $$f(-x)=-f(x)$$), and since we have a $$\dfrac{\tan(x_1)}{\tan(x_2)},x_1\neq x_2$$, we have$$\dfrac{\tan(-x_1)}{\tan(-x_2)}\implies\dfrac{\require{cancel}\cancel{(-1)}\tan(x_1)}{\cancel{(-1)}\tan(x_2)}=\dfrac{\tan(x_1)}{\tan(x_2)},\text{ where }x_1,x_2\in\mathbb{R}^+$$and then we have $$\cos(x)$$, an even function (meaning $$f(-x)=f(x)$$), so that's how we get $$\cos\left(-\frac{7\pi}8\right)=\cos\left(\frac{7\pi}8\right)$$ and the same thing for $$\cos\left(-\frac{5\pi}8\right)$$

My question

Did I evaluate the integral correctly, or how would I be able to evaluate it/does it diverge?

Notes

[$$1$$]Sorry about just copying the answer, losing the steps for an evaluation of an integral doesn't happen to me often and it really shouldn't be happening at all.

• Observe that $$\;\frac{\cos^2x}{\sin x}=\csc x-\sin x\;$$ Commented Sep 6, 2023 at 19:30
• $$\cos^2x/\sin x=\frac{cos^2x\sin x}{1-\cos^2x}$$ and substitute $u=\cos x.$ Commented Sep 6, 2023 at 19:36
• Any time you have a rational function of $\sin x$ and $\cos x,$ you can always use the tangent half-angle substitution. It isn't needed here, but it always works in these cases, turning the integral in an integral of a rational function, which in turn you can solve with partial fractions. en.wikipedia.org/wiki/Tangent_half-angle_substitution Commented Sep 6, 2023 at 19:52

We have (for an easier method):$$\int\dfrac{\sin(x)}{\tan^2(x)}dx=\int\dfrac{\cos^2(x)}{\sin(x)}dx$$Now, in a comment by DonAntonio, we have$$\int\dfrac{\cos^2(x)}{\sin(x)}dx\implies\int\csc(x)-\sin(x)dx$$Now we have$$\int\csc(x)dx-\int\sin(x)dx=\ln(\tan(x/2))+\cos(x)\\=\ln\left(\dfrac{1+\cos(x)}{1-\cos(x)}\right)+\cos(x)$$which we will be evaulating from $$-7\pi/8$$ to $$-5\pi/8$$, which gets us$$\ln\left(\dfrac{(1+\cos(5\pi/8))(1-\cos(7\pi/8))}{(1-\cos(5\pi/8))(1+\cos(7\pi/8))}\right)+\cos(5\pi/8)-\cos(7\pi/8)\\\approx0.6844527006$$
[1]How to evaluate the integral $$\int_1^9\frac{dx}{x\sqrt{81-x^2}}$$ by CrSb0001