$\int\frac{\sin\left(x\right)}{\cos\left(x\right)}\,\mathrm{d}x$ by substitution 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? 
 A: $\displaystyle \int\left(\frac{\sin\left(x\right)}{\cos\left(x\right)}\right)\,\mathrm{d}x$
As you noticed, it's easy to let $u = \cos (x)$, and that's how I would recommend it. But suppose we weren't being as slick as you were, but we still wanted to let $u = \sin (x)$. Then the problem comes from $du = \cos (x)$, which isn't there.
But $\dfrac{1}{\cos x} = \dfrac{\cos x}{\cos^2 x}$, and combining $u = \sin x$ with $\cos^2 x = 1 - \sin^2 x$, we get that $\dfrac{\cos x }{\cos^2 x} = \dfrac{du}{1 - u^2}$.
Thus $\displaystyle \int \dfrac{\sin x}{\cos x}dx = \int \dfrac{udu}{1-u^2}$, which is what you called $\int f(x)$. 
A: What you did is fine. One can view it as carrying out the standard strategy when we have a product of integer powers of sines and cosines, with at least one of the powers odd.  In this case, both powers are odd. 
Note that
$$\frac{\sin x}{\cos x}=\frac{\sin x\cos x}{\cos^2 x}=\frac{\sin x\cos x}{1-\sin^2 x}.$$
Then the substitution $u=\sin x$ transforms our integral to
$$\int \frac{u}{1-u^2}\,du.$$
Remark: If we had instead something like $\int\frac{\sin^4 x}{\cos x}\,dx$, then the same strategy of substituting for $\sin x$ would work. The substitution $u=\cos x$ would be less attractive.
A: $$
\begin{aligned}
\int \frac{\sin x}{\cos x} d x & =-\int \frac{d(\cos x)}{\cos x} \\
& =-\ln |\cos x|+C \\
& =\ln |\sec x|+C
\end{aligned}
$$
A: 
That's all. Easy peasy
Cos = z
-sinxdx= dz
