I am asked to solve $\int_0^\frac{\pi}{4}\tan x\, \mathrm{d}x$.
This is what I did:
$$ \begin{align} &\int_0^\frac{\pi}{4}\tan x \,\mathrm{d}x&\\ = {} &\int_0^\frac{\pi}{4}\frac{\sin x}{\cos x}\, \mathrm{d}x&\\ = {} &\int_0^\frac{\pi}{4}\sin x\frac{-1}{-\cos x} \,\mathrm{d}x&\\ = {} &-\int_0^\frac{\pi}{4}\varphi'(x)\frac{1}{\varphi(x)} \,\mathrm{d}x &\text{where $\varphi(x):=-\cos x$} \\ = {} &-\int_{\varphi(0)}^{\varphi(\frac{\pi}{4})} \frac{1}{z} \,\mathrm{d}z \\ = {} &-\int_{-1}^{-\frac{1}{\sqrt{2}}} \frac{1}{z}\, \mathrm{d}z \\ = {} &\Big[\ln z\Big]_{-1}^{-\frac{1}{\sqrt{2}}} \\ = {} &\ln \left(-\frac{1}{\sqrt{2}}\right) - \ln (-1) \end{align} $$
And this is where I am stuck, because the solution is definitely not a complex number. I know the correct answer (it's $-\ln\left(\frac{1}{\sqrt{2}}\right)$, my problem is that I don't know where I made a mistake.
It turns out that $\displaystyle\int\frac1z\,\mathrm dz=\log|z|$, not $\log z$.