TITLE: Fallacious proof involving trigonometry
QUESTION [15 upvotes]: Which step in the following incorrect proof is fallacious? Is it something with the use of indefinite integrals or with the domain and range of trignometric functions? I encountered this fallacious proof here.
$$
\int\tan(x)\,dx=\int\tan(x)\,dx
$$
substitute $\tan(x)$ :
$$
\int\tan(x)\,dx=\int\sin(x)\sec(x)\,dx
$$
Integrate by parts, assume 
$$
u=\sec(x),dv=\sin(x)\,dx
$$
Therefore,
$$
\int\tan(x)\,dx=-\sec(x)\cos(x)+\int\cos(x)\tan(x)\sec(x)\,dx
$$
but $\cos(x)\sec(x)=1$ so:
$$
\int\tan(x)\,dx=-1+\int\tan(x)\,dx
$$
we subtract both sides by $\int\tan(x)\,dx$ :
$$
\int\tan(x)\,dx-\int\tan(x)\,dx =-1+\int\tan(x)\,dx-\int\tan(x)\,dx
$$
then:
$0=-1$
Thanks in advance for any help.

REPLY [3 votes]: This is a common mistake: two antiderivatives differ by a constant (assuming we're working with functions defined over an interval. Use a fixed bound, that is, a uniquely determined antiderivative:
\begin{align}
\int_0^x \tan t\,dt
&=\int_0^x \sin t\frac{1}{\cos t}\,dt \\[6px]
&=\Bigl[-\cos t\frac{1}{\cos t}\Bigr]_0^x-
\int_0^x(-\cos t)\left(-\frac{1}{\cos^2t}(-\sin t)\right)\,dt \\[6px]
&=[1-1]+\int_0^x\tan t\,dt
\end{align}
No contradiction (and no progress either).