Integrate $1/x$ by parts. $$\int \frac{\mathrm{d}x}{x}$$
If I integrate this by parts ($\displaystyle u=\frac{1}{x}, \mathrm{d}u = -\frac{\mathrm{d}x}{x^2}, \mathrm{d}v= \mathrm{d}x, v = x$), then why does this happen?
$$\int \frac{1}{x} \: \mathrm{d}x = u v - \int v \:\mathrm{d}u = \frac{x}{x} - \int x\left(\frac{-1}{x^2}\right) \:\mathrm{d}x=1+\int \frac{1}{x}\:\mathrm{d}x$$
So $\displaystyle\int \frac{1}{x}\:\mathrm{d}x = 1 + \int \frac{1}{x} \:\mathrm{d}x$ and cancel out both sides of $\displaystyle\int \frac{1}{x} \:\mathrm{d}x$ and I get $0=1$. How can I find the error in the process because right now I cant see it.
 A: The antiderivative is well-defined only up to adding in a local* constant. To be more precise, we might explicitly specify an equivalence relation rather than writing equality. That is, we might write something like
$$ \int \frac{1}{x} \, \mathrm{d}x \equiv \ln x $$
where the equivalence sign means

$ f \equiv g$ if and only if there exists a local constant $C$ such that, for all values of $x$, $g(x)-f(x) = C$

(note that a single value of $C$ is supposed to work for all $x$)
Now, with this convention, your equation should be written
$$ \int \frac{1}{x} \, \mathrm{d}x \equiv 1 + \int \frac{1}{x} \, \mathrm{d}x $$
And then when we subtract off the integral from both sides (which we can do, because $\int f \mathrm{d}x \equiv \int f \mathrm{d}x$), we get
$$ 0 \equiv 1  $$
And this is true: e.g. we could pick $C=1$ if we substitute in the definition of equivalence.
By convention we know that if an antiderivative appears in an equation, that equation is supposed to be an equivalence, not an equality. By writing the equivalence relation explicitly, it helps us avoid a mistake -- when we cancel out the antiderivative, we might mistakenly forget that the result is still only supposed to be an equivalence.

*: In many situations, "local constant" simply means "constant". However, in situations where we are interested in a domain that is made up of disconnected intervals -- e.g. when considering the function $1/x$ on the domain of all nonzero real numbers -- there can be different constants on each interval. e.g. $f'(x) = 1/x$ if and only if there are constants $A$ and $B$ such that
$$ f(x) = \begin{cases} \ln(x) + A & x > 0 \\ \ln(-x) + B & x < 0 \end{cases} $$
or put differently, $ f(x) = \ln |x| + C(x)$, where $C$ is the function
$$ C(x) = \begin{cases} A & x > 0 \\ B & x < 0 \end{cases} $$
The terminology "local constant" is in reference to the idea that near any particular point in the domain -- i.e. 'local' to that point -- the function actually is constant. e.g. near $a = 0.01$, $C(x)$ is simply the constant value $A$ for any $x$ with $|x-a| < 0.01$.
A: You cannot cancel out $\int \frac{1}{x}dx$ on both sides, because $\int \frac{1}{x}dx$ is a family of functions (up to a constant factor $C$).
A: Integration by parts is based on the product rule:
$$
(f(x)\cdot g(x))'=f'(x)g(x)+f(x)g'(x)\\
$$
Integrate both sides:
$$
\int(f(x)\cdot g(x))'\,dx=\int[f'(x)g(x)+f(x)g'(x)]\,dx\implies\\
f(x)\cdot g(x)+C=\int f'(x)g(x)\,dx+\int f(x)g'(x)\,dx\implies\\
\int f'(x)g(x)\,dx=f(x)\cdot g(x)-\int f(x)g'(x)\,dx+C,\ C\in\mathbb{R}.
$$
$\int(f(x)\cdot g(x))'\,dx=f(x)\cdot g(x)+C$ because if $f'(x)=F(x)$, then $\int F(x)\,dx=f(x)+C$ since $(f(x)+C)'=F(x)$ (note that this is not the same $f(x)$ as in the example above). In other words, $\int f'(x)\,dx=f(x)+C$.
There is always that constant of integration which they always drop in that integration by parts formula that you see in textbooks.
So, your problem really should look like this:
$$\int\frac{1}{x}\,dx = 1 + \int\frac{1}{x}\,dx+C,\ C\in\mathbb{R}.$$
And that is a true equality statement if $C=-1$.
