Trouble understanding solving integrals like linear equations I know that some integrals on solving by parts end up with the same integral on the right side, and then the integral is assumed to be $I$ or some variable, and then linearly solved. For example, 
$$I = \int e^x \cos x \ dx$$ 
$$u = e^x,\ dv = \cos x \ dx, \ du = e^x \ dx,\ v = \sin x$$
$$\int u dv = uv - \int v \ du$$
$$I = e^x \sin x - \int e^x \sin x \ dx$$ 
Similarly, 
$$u = \cos x,\ dv = e^x \ dx, \ du = -\sin x \ dx,\ v = e^x$$
$$\int u dv = uv - \int v \ du$$
$$I = e^x \cos x - \int - \ e^x \sin x \ dx$$ 
$$I = e^x \cos x + \int e^x \sin x \ dx$$
Adding the two values of $I$ and dividing by 2, we obtain
$$I = \frac{e^x(\sin x + \cos x)}{2} + C$$
But when I tried this for $1/x$,
$$I = \int \frac{dx}{x}$$
$$u = \frac{1}{x},\ dv = dx, \ du = -\frac{dx}{x^2},\ v = x$$
$$\int u dv = uv - \int v \ du$$
$$I = x\frac{1}{x} - \int - x \frac{1}{x^2} \ dx$$
$$I = 1 + \int \frac{1}{x} \ dx$$
$$I = 1 + I$$
What is happening here?
 A: Given an interval $I\subset{\mathbb R}$ and a function $$f:\quad I\to{\mathbb R}, \qquad x\mapsto f(x)\ ,$$  the indefinite integral $\int f(x)\>dx$ is a family of functions on $I$, usually denoted by "$\>F(x)+C\>$". For the purpose of this answer let's write $\langle F(x)\rangle$, or simply $\langle F\rangle$, instead .
It is a little exercise to prove that such families can be added and scaled according to
$$\langle F\rangle+\langle G\rangle:=\langle F+G\rangle,\qquad \lambda\langle F\rangle:=\langle \lambda F\rangle\ ,$$
so that the set of all these families forms a real vector space. This then allows for arguments of the kind used in the calculation of integrals $\int e^x\>\cos x\>dx$, and similar.
A: The only thing you've done wrong with the integration of $\dfrac 1x$ is to assume at the last step that the constant of integration was $0$.  There are constants of integration floating around in the first example ($\int e^x\cos x$) attached to the indefinite integrals, but they all get merged together into the final ${}+C$.
Let $\displaystyle\int\dfrac1x~dx = F(x)+C$. Your deduction $I=1+I$ is $F(x)+C_1=1+F(x)+C_2$ or $0=1+C$ where $C=C_2-C_1$.
In the other examples of integration by parts you've seen using this technique, the integrals end up as $kI=F(x)+C$ for some $k\ne0$, so $I=\dfrac1kF(x)+C'$. Unfortunately in your case, $k=0$ and we can't deduce much about $I$ from $0I=0$.
