Constant of integration change

So, sometimes the constant of integration changes, and it confuses me a bit when and why it does. So for example, we have a simple antiderivative such as $$\int \frac{1}{x} dx $$ and we know that the result is $$\log|x| + C$$ and the domain is $$x\in\mathbb R \backslash \{0\} $$ If we want to show all the solutions, we need to do something like $$\begin{cases} \log x+C_1 & x>0\\ \log(-x)+C_2 & x<0 \end{cases}$$

Do we need to do change the constant every time there is a gap in the domain or is it just when the expression changes? For example, $$ \int \frac {x^5} {x^2-1} dx$$ which is $$ \frac {1} {2} \log |x^2-1| + \frac {x^4} {4} + \frac {x^2}{2} + C$$ and the domain is $$x \in \mathbb R \backslash \{-1,1\}$$ When we want to write all the solutions, is it something like $$ \begin{cases} \ \frac {1} {2} \log (x^2-1) + \frac {x^4} {4} + \frac {x^2}{2} + C_1 & x>1\\ \frac {1} {2}\log (-x^2+1) + \frac {x^4} {4} + \frac {x^2}{2} + C_2 & -1<x<1\\ \frac {1} {2} \log (x^2-1) + \frac {x^4} {4} + \frac {x^2}{2} + C_3 & x<-1 \end{cases}$$ or is it that since the the first and last expression are the same they only have one constant associated? Meaning, the solutions are actually $$ \begin{cases} \ \frac {1} {2} \log (x^2-1) + \frac {x^4} {4} + \frac {x^2}{2} + C_1 & x \in \mathbb R \backslash [-1, 1]\\ \frac {1} {2}\log (-x^2+1) + \frac {x^4} {4} + \frac {x^2}{2} + C_2 & -1<x<1\\ \end{cases}$$


"Do we need to do change the constant every time there is a gap in the domain [...]?" The answer is Yes: the generic C stands for a locally constant function - a function constant on intervals. The values on disjoint intervals may be different.


To expound a bit on Catalin Zara's answer:

Your answer should give all possible antiderivatives; i.e., if you plug in any particular combination of constants for the generic constants $C_1, C_2, \dots$, you get a function which, when you differentiate, gives you the integrand. So the answer with three constants is more general than the answer with two constants; and you can check that if $C_1$ and $C_3$ are different, you still get a function with derivative $\frac{x^5}{x^2-1}$


Since the specific problem you pose has been nicely solved through Y. Forman's and Catalin Zara's answers, I'd like to add some more "theoritic" information about the way we define the $\int f(x)dx$ and that so-called constant of integration.

Let $\mathcal{D}(\mathbb{R})$ be the set of all differentiable functions $f:\mathbb{R}\to\mathbb{R}$, so: $$\mathcal{D}(\mathbb{R}):=\{f:\mathbb{R}\to\mathbb{R}|f\text{ is differentiable}\}$$

Now, let us consider the following relation in $\mathcal{D}(\mathbb{R})$: $$f\sim g\Leftrightarrow f'(x)=g'(x)$$ It is clear that $\sim$ is an equivalence relation, since:

  • $f\sim f\Leftrightarrow f'(x)=f'(x)$ for every $f\in\mathcal{D}(\mathbb{R})$,
  • $f\sim g\Rightarrow g\sim f$, since $f'(x)=g'(x)\Leftrightarrow g'(x)=f'(x)$,
  • $f\sim g\ \land\ g\sim h\Rightarrow f\sim h$, since $f'(x)=g'(x)\ \land g'(x)=h'(x)\Rightarrow f'(x)=h'(x)$.

So, consider now the quotient space: $$E:=\mathcal{D}(\mathbb{R})/\sim$$

Since $\mathcal{D}(\mathbb{R})$ is a linear space over $\mathbb{R}$, the same applies for $E$.

Now, let us examine which is the zero element of $E$: $$[0]=\{f\in\mathcal{D}(\mathbb{R})|f'=0\}$$ Since, in our case $f$'s domain is always $\mathbb{R}$, $[0]=[c]$ for every $c\in\mathbb{R}$.

Now, let $f,g\in\mathcal{D}(\mathbb{R})$. Then we have that: $$f\sim g\Leftrightarrow[f]=[g]\Leftrightarrow [f]=[g]+[0]\tag{$\star$}$$ Now, let us also introduce the following notation: $$\int f(x)dx:=[f]$$ Then, with the above notation $(\star)$ becomes: $$f\sim g\Leftrightarrow\int f(x)dx=\int g(x)dx+c,\ \text{for some }c\in\mathbb{R}$$ since $[0]=[c]$ for every $c\in\mathbb{R}$, which reminds us of the relation in question.

Now, we can, in a similar way define $\mathcal{D}(A)$, for every $A\subseteq\mathbb{R}$ on which we can define differentiation (e.g. finite unions of open intervals). But, on that case, as has been mentioned, we need to bare in mind that $[0]$ is defined as follows: $$[0]=\{f\in\mathcal{D}(A)|f'=0\}$$ with the notion this has on $A$. So, if $A=(0,1)\cup(1,2)$, every function that is constant on $(0,1)$ and $(1,2)$ seperately - not necessarily with the same value on them - belongs to $[0]$. So, we also have that: $$f\sim g\Leftrightarrow\int f(x)dx=\int g(x)dx+h,\ h\in[0]$$ Now, it is clear that the general case demands to choose different constants on every connected component of the domain $A$.


Here is a 1-line compactification of Βασίλης Μάρκος' answer $\ddot\smile$

It can be shown that on every sub-interval of the domain of the original function, any two anti-derivatives differ by an additive constant, but constants for different sub-intervals can very well be different.