Integrating $\int (x+1)^2 dx$ two ways gives different results: $\frac13 x^3+x^2+x$ vs $\frac13 x^3+x^2+x+\frac13$. Why? I was trying to compute $$\int (x+1)^2 \, dx~,$$ which is a really easy function to integrate. 
But the thing is that I write the function as $x^2 +2x+1$ and the result I got was $\frac{x^3}{3} +x^2 +x$. 
But then I tried to integrate it using substitution; I called $u=x+1$, so the function I had to integrate was $$\int (u)^2 \, du~,$$ and the result is $\frac{u^3}{3}$ and then $\frac{(x+1)^3}{3}$, which is equal to $\frac{x^3}{3} +x^2 +x+\frac{1}{3}$ and that's different from the previous result!
 A: Remember that when evaluating an indefinite integral, you have an infinite family of solutions.  Since you lose constant factors when differentiating, both functions are solutions.  That's why we add a "$+C$" to our solutions. 
A: WARNING while dealing with INDEFINITE INTEGRALS!!
When you solve some indefinite indefinite integral you should always add a constant in your final result (why?). Remember that indefinite integral is nothing but anti-derivative. Therefore, whenever you integrate you miss a constant which disappears because the derivative of constant is $0$.
A: The substitution is the way to solve your integral and the constant is OK. because it drops under differentiation. 
A: Both the ways actually give the same answer. The $~\frac{1}{3}~$ part is a constant which can be written as '$~C~$' , which is just the constant part of indefinite integration (which sometimes people don't write). If you put limit on integration e.g.,: $~0\le x\le 1~$.
You'll see that both the approaches yield the same answer. 
Note: When you substitute $~x+1~$ with $~u~$, the limit changes from $~(0, 1)~$  to $~(1, 2)~$. 
A: You have, effectively, just modified the arbitrary constant that is associated with each (here only one) connected component of the integrand's domain. Note that the term $\frac{1}{3}$ is a constant, containing no occurrences of $x$.
The "true" answer to an indefinite integration problem
$$\int f(x)\ dx$$
where $\mathrm{dom}(f)$ is connected, is the set of functions
$$\{ x \mapsto [F(x) + C] : C \in \mathbb{R} \}$$
for any function $F$ such that $F' = f$: that is, all those whose values are offset from some representative by a constant shift. Note that if you take either $x \mapsto \frac{1}{3} x^3 + x^2 + x$ or $x \mapsto \frac{1}{3} x^3 + x^2 + x + \frac{1}{3}$ as being $F$, the other will differ from it by a constant shift $C$ only (respectively $\frac{1}{3}$ and $-\frac{1}{3}$), hence both belong to this set and, moreover (considering all possible $C$) the set is uniquely and hence well-defined.
