Integrating $\sin(x)x^2$ by parts, why do we only add $C$ at the end?

The familiar formula for integration by parts is $$\int udv= uv-\int vdu $$

Now if you like to add a constant to your $v$ you get $$\int udv= u(v+c)-\int (v+c)du = uv+uc-\int vdu -c\int du = $$

$$uv+uc-\int vdu -cu = uv- \int vdu $$

Which is exactly the same result due to cancelation of $cu$ and -$cu$


Let's keep those $C_{i}$'s in those steps and show you that things still cancel out:

$$\int{x^{2}sinxdx}=-x^{2}cosx+C_{1}x^{2}-2C_{1}\int{xdx}+2\int{xcosxdx}$$

We get $$\int{x^{2}sinxdx}=-x^{2}cosx+C_{1}x^{2}-2C_{1}\int{xdx}+2xsinx+2C_{2}x-2\int{sinxdx}-2C_{2}\int{dx}$$

Then $$\int{x^{2}sinxdx}=-x^{2}cosx+C_{1}x^{2}-C_{1}(2)\frac{x^{2}}{2}+C_{3}+2xsinx+2xC_{2}+2cosx+C_{4}-2C_{2}x+C_{5}$$

Collection of like terms and letting $C=C_{3}+C_{4}+C_{5}$, we get $$\int{x^{2}sinxdx}=-x^{2}cosx+2xsinx+2cosx+C$$


For $f $ and $ g$ $ C^1$ at some intervalle,

The integration by parts is based on the identity $$(fg)'=f'g + fg'$$

which yields to

$$\int f'g = fg - \int fg'$$

If you write

$$\int f'g = (f+C_1)g - \int fg'$$ the result will be false.

You should write

$$\int f'g = (f+C_1)g - \int (f+C_1)g'$$ To satisfy the first identity.