I'm trying to solve the following integral: $$\int\frac{\sin\left(x\right)}{\cos\left(x\right)}\,\mathrm{d}x$$ Using the substitution method with the substitution $u = \sin\left(x\right)$.
The exercise has two parts: the first one is using the substitution $u = \cos\left(x\right)$. No problem. I'm having difficulties with the second part, which is using the substitution $u = \sin\left(x\right)$.
I spent a couple of hours with the exercise before asking here, and after some trials I got this: $$\int f\left(g\left(x\right)\right)g'\left(x\right)\,\mathrm{d}x = \int f\left(u\right)\,\mathrm{d}u$$ $$g\left(x\right) = \sin\left(x\right)$$ $$g'\left(x\right) = \cos\left(x\right)$$ $$f\left(x\right) = \frac{x}{\cos^2\left(\arcsin(x)\right)} = \frac{x}{1 - x^2}$$ $$\int f\left(u\right)\,\mathrm{d}u = -\frac{1}{2}\log|1 - u^2| + C = -\frac{1}{2}\log|1 - \sin^2\left(x\right)| + C$$ $$1 - \sin^2\left(x\right) = \cos^2\left(x\right)$$ $$\int\frac{\sin\left(x\right)}{\cos\left(x\right)}\,\mathrm{d}x = -\frac{1}{2}\log|\cos^2\left(x\right)| + C = -\log|\cos\left(x\right)| + C$$ But it feels too complicated, $f\left(x\right)$ was really hard for me to discover. What am I missing?