The constant of integration during integration by parts

When integrating by parts, at what point does the constant come in?

The rule has always been like this:

$$ \int u\,dv = uv - \int v\,du $$

The explanation is that this the "reversal" of the product rule:

$$ d(uv) = u\,dv + v\,du $$

But if that is the case, shouldn't a $C$ appear when you integrate both sides?

$$ uv = \int u\,dv + \int v\,du + C \quad ? $$

I've been told to just ignore the $C$ because it will appear in the final integral anyway, like this:

$$ \begin{align*} \int xe^x\,dx &= xe^x - \int e^x\, dx \\ &= xe^x - e^x + C \end{align*} $$

Fine. But what happens when integrating by parts results in the exact same integral as the original?

Like this, first no $C$:

$$ \begin{align*} \int e^x \sin x \, dx &= e^x \sin x - \int e^x \cos x \, dx \\ &= e^x \sin x - \left( e^x \cos x + \int e^x \sin x \, dx \right) \end{align*}$$

Then out of nowhere, a $C$ appears:

$$ \begin{align} 2\int e^x \sin x \, dx &= e^x \sin x - e^x \cos x + C \\ \int e^x \sin x \, dx &= \frac{1}{2} e^x \sin x - \frac{1}{2} e^x \cos x + C \end{align} $$

We know the final result has to contain a $C$, but where does it come from? No integral is being evaluated here, all we did was move the integral from the right to the left.

This is one thing that I think is not being properly taught.


Here's one way to think about it: we reach this step: $$ \int e^x \sin x \, dx = e^x \sin x - e^x \cos x - \int e^x \sin x \, dx $$ And for our next step, we'd like to add $\int e^x \sin x \, dx$ on both sides, so we do. $$ \int e^x \sin x \, dx + \int e^x \sin x \, dx = e^x \sin x - e^x \cos x - \int e^x \sin x \, dx + \int e^x \sin x \, dx \\ \int [e^x \sin x + e^x \sin x] \, dx = e^x \sin x - e^x \cos x + \int [e^x \sin x - e^x \sin x] \, dx \\ \int 2[e^x \sin x] \, dx = e^x \sin x - e^x \cos x + \int 0\, dx \\ 2\int e^x \sin x \, dx = e^x \sin x - e^x \cos x + C $$ The intuition is that when we take the antiderivative twice in the same equation, we don't guarantee that the result is the same each time. So, the equation $$ \int e^x \sin x \, dx = e^x \sin x - e^x \cos x - \int e^x \sin x \, dx $$ Is really something to the effect of $$ F(x) + C_1 = e^x \sin x - e^x \cos x - [F(x) + C_2] $$ Where $F$ is some antiderivative of $e^x \sin x$.