Q:

How to change the trigonometric identity to sec^2(x)?

Evaluate the definite integral:
$$\int_{\frac{\pi}{8}}^\frac{\pi}{4}(\csc(2\theta)-\cot(2\theta)\ d\theta$$
Finding the derivative gives me this, which is confirmed by the steps in Wolfram Alpha. This is the answer as the last step that I also got.
$$-2\csc(2\theta)\cot(2\theta)+2\csc^2(2\theta)$$
But then at the top, Wolfram Alpha says the answer is this:
$$\sec^2\theta$$
How did they get that?
Edit: I just realized that I'm solving the question wrong; I'm supposed to find the antiderivative and not the derivate. Either way, I wanted to know how the identity was found.

A:

Steps are:
\begin{equation}
-2\csc(2\theta)\cot(2\theta) + 2\csc^{2}(2\theta)
\end{equation}
\begin{equation}
-2* \frac{1}{2\sin(\theta)cos(\theta)} * \frac{cos(2\theta)}{sin(2\theta)} + 2\csc^{2}(2\theta)
\end{equation}
Simplify.
\begin{equation}
-2 * \frac{1-2\sin^{2}(\theta)}{\sin^{2}(2\theta)} + 2\csc^{2}(2\theta)
\end{equation}
Then
\begin{equation}
\frac{-2}{\sin^{2}(2\theta)} + \frac{1}{\cos^{2}(\theta)} + 2\csc^{2}(2\theta)
\end{equation}
\begin{equation}
\frac{-2}{\sin^{2}(2\theta)} + \frac{1}{\cos^{2}(\theta)} + \frac{2}{\sin^{2}(2\theta)}
\end{equation}
Clearly, the -2 and +2 terms cancel, and you're left with $\frac{1}{\cos^{2}(\theta)}$ which is the same as $\sec^{2}(\theta)$

