Evaluate $\int \frac{1}{\sin x\cos x} dx $
Solution 1:
If I take the derivative of your second answer (call it $g(x)$), I get: \begin{eqnarray*} \frac{dg}{dx} & = & -\frac{-\sin x}{\cos x} + \frac{\sin x}{2(1-\cos x)} + \frac{-\sin x}{2(1+\cos x)}\\ & = & \frac{\sin x\left(1-\cos^2 x + \frac{1}{2}\cos x(1+\cos x) - \frac{1}{2}\cos x(1-\cos x)\right)}{\cos x(1-\cos x)(1+\cos x)}\\ & = & \frac{\sin x\left( 1- \cos^2 x + \frac{1}{2}\cos x + \frac{1}{2}\cos^2 x - \frac{1}{2}\cos x + \frac{1}{2}\cos^2 x\right)}{\cos x(1-\cos^2 x)}\\ & = & \frac{\sin x}{\cos x\>\sin^2 x} = \frac{1}{\cos x\sin x}. \end{eqnarray*} So I'm not sure why Mathematica says the second method is not "the right answer".
Solution 2:
This may be an easier method $$\int\frac{1}{\sin{x} \cdot \cos{x}} \ dx = \int\frac{\sec^{2}{x}}{\tan{x}} \ dx$$ by multiplying the numerator and denominator by $\sec^{2}{x}$
Solution 3:
Taking log of $\rm\ sin^2(x)\ =\ 1 - cos^2(x)\ = (1-cos(x))\ (1+cos(x))\ $ shows both answers identical