Fallacious proof involving trigonometry 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.
 A: Remember the mantra:  "... plus a constant".  $\int x^2 = \frac {x^3}{3}$ .... PLUS A CONSTANT.
So in your proof:
"Therefore $\int\tan(x)dx=-\sec(x)\cos(x)+ C + \int\cos(x)\tan(x)\sec(x)dx$ "
"but $\cos(x)\sec(x)=1$ so:"
"$\int\tan(x)dx=-1 + C +\int\tan(x)dx$"
"We subtract both sides by $\int\tan(x)dx$"
"$\int\tan(x)dx-\int\tan(x)dx = -1 + C +\int\tan(x)dx - \int\tan(x)dx$
"Then:"
"$0 = -1 +C$"
$C = 1$
And therefore we have proven that   .... $1$ is a constant.
A: These are indefinite integrals; you need to add $C$. It's true that $0+C_1 = -1+C_2$ for some constants $C_1$ and $C_2$.
(And if they were definite integrals, the $0$ and $-1$ would wash out when we subtracted the upper bound from the lower.)
More specifically, I would say that the next-to-last line,
$$
    \int \tan x\,\text{d}x = -1 + \int \tan x\,\text{d}x
$$
is still true. But when you're just canceling the integral of $\tan x$ from both sides, you're forgetting that the integrals are only defined up to a constant, and that constant absorbs the $-1$. What the line above is really saying is that there's some function $F(x)$ whose derivative is $\tan x$ for which
$$
    F(x) + C_1 = -1 + (F(x)+ C_2)
$$
which is perfectly true for some constants $C_1$ and $C_2$.
Alternatively, we can think of the problem as simplifying
$$
    \int \tan x\,\text{d}x - \int \tan x\,\text{d}x = \int 0\,\text{d}x
$$
to $0$: the $+C$ doesn't disappear just because we're integrating $0$.

These two integrals are actually a good example of why we need to add $C$ for an indefinite integral: two antiderivatives of a function are not guaranteed to be equal, only to differ by an arbitrary constant.
A: The fallacious step is the one where you forgot that $\int \tan(x)\,dx$ is an equivalence class or family of functions.
In other words, the problem $f(x) = \int \tan(x)\,dx$ has a solution set
consisting of infinitely many functions that might be named $f$ in that equation.
Every function in the solution set has the form
$$ f(x) = \log(\cos (x)) + C $$
where $f$ is a function over the interval $(-\pi/2,\pi/2)$ 
and $C$ is some constant.
The difference $A - B$ when $A$ and $B$ both are equivalence classes consists of all possible values $a - b$ where $a \in A$ and $b \in B.$
Therefore,
$$ \int \tan(x)\,dx - \int \tan(x)\,dx = 
\{f: (-\pi/2,\pi/2)\to\mathbb R\mid
 (\exists c\in\mathbb R)(\forall x\in\mathbb R) f(x) = c\},$$
that is, the difference of the two integrals is the set of
all real-valued constant functions over the same domain as 
$\int \tan(x)\,dx,$
because for any real number there is some member of $\int \tan(x)\,dx$
that you can subtract from another member of $\int \tan(x)\,dx$
to get the desired number as your difference.
Now it is certainly true that there are constant functions
$C_1$ and $C_2$ such that 
$$ C_1 = -1 + C_2,$$
but it is not true that both of those functions will always be the
zero function, and you cannot conclude that $0 = -1.$

If all this talk of equivalence classes is too much,
you can just remember to add the constant of integration everywhere
you use an indefinite integral.
Also make sure that if you have two integrals, each one gets its own constant of integration, even if they are integrals of the same integrand.
You can replace the sum or difference of two constants of integration
by a new constant, but you cannot assume their difference is zero.
A: 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).
A: The already-given answers are good, but I think it's illuminating to point out that the "paradox" vanishes if we try to follow the same logical chain it without the antiderivatives.  For the integration by parts step, we use the identity $u' v = (uv)' - u v'$.  We then have
\begin{align*}
\tan x &= \tan x \\ 
&= \sin x \sec x \\
&= - \frac{d}{dx}(\cos x) \sec x \\
&= - \frac{d}{dx} (\cos x \sec x) + \cos x \frac{d}{dx} (\sec x) \\
&= - \frac{d}{dx} (\cos x \sec x) + \cos x \sec x \tan x \\
&= - \frac{d}{dx} (1) + \tan x
\end{align*}
As you can see, this equation is correct because the derivative of $1$ is zero.  If we then try to take the antiderivative of each side, we have
$$
\int \tan x \, dx= -\int \frac{d}{dx} (1)  \, dx + \int \tan x \, dx
$$
which is only a problem if you insist that 
$$
\int \frac{d}{dx} (1)  \, dx = 1.
$$
As to why this last move isn't valid, I'll refer you to the fact (pointed out by multiple answerers) that antiderivatives aren't "really" functions;  they're equivalence classes of functions, where two functions are equivalent if they differ by a constant.  
A: As an adjunct to Misha Lavrov's answer, this is probably not the first time you have encountered this phenomenon.
In trigomometry, one might be faced with $\cos(\theta) = \frac{\sqrt{2}}{2}$.  The solutions to this equation are, of course, $\theta = \pm \cos^{-1}\left( \frac{\sqrt{2}}{2} \right) + 2 \pi k = \pm \frac{\pi}{4} + 2 \pi k$, for any integer $k$.  Some people normalize these so that all the particular angles are positive, so $\theta = \frac{\pi}{4} + 2 \pi k$ or $\theta = \frac{7\pi}{4} + 2 \pi k$, for any integer $k$.
Well this means \begin{align*}
    \left\{\frac{-\pi}{4} + 2 \pi k, k \in \mathbb{Z}\right\} &= \left\{\frac{7\pi}{4} + 2 \pi k, k \in \mathbb{Z} \right\} & &\text{True.}  \\  
    \frac{-\pi}{4} &= \frac{7\pi}{4} & &\text{False.}  \\  
\end{align*}
Just because two sets are equal, which is what you have at
$$ \int \tan x \,\mathrm{d}x = -1 + \int \tan x \,\mathrm{d}x  \text{,}  $$
does not mean that two randomly selected elements of those sets are equal.
