Are indefinite integrals unique up to the constant of integration?

Let $f$ and $g$ two antiderivative of $x^2$ then we have

$$\frac{d}{dx}(f(x)-g(x))=x^2-x^2=0$$ hence $$f(x)-g(x)=\text{constant}$$


It was mentioned that the domain must be connected. Example: Sometimes people write $$ \int \frac{dx}{x} = \ln|x| + C . \tag{1}$$ But of course an antiderivative on the domain $(-\infty,0)\cup(0,+\infty)$ could have different values of $C$ on the positive part and on the negative part of the domain. Making (1) a questionable thing to write.


Hint: consider the difference of primitives, the derivative of which vanishes. now if the domain is connected then this implies that the difference must be a constant (this follows from the mean value theorem).

To expand on git guds fitting remark above: take the domain to be $\Omega:=(-1,0)\cup(0,1)$ then the characteristic function $\chi_{(0,1)}$ is differentiable on $\Omega$ and its derivative is zero. If $g$ is a primitive of $f$ on $\Omega$, then $g+\chi_{(0,1)}$ is another primitive but the difference $\chi_{(0,1)}$ is not constant.