Antiderivative of a piecewise continuous function

calculus

I have a silly conceptual confusion. Let's consider a piecewise continuous function: $$
f(x)=\begin{cases}
x & \text{if } x\in(0,1),
\\ 1 & \text{if } x\in[1,2),
\\ 3-x & \text{if } x\in [2,3).
\end{cases}
$$

By definition $f(x)$ is continuous on $(0,3)$. Then, (please correct me if I'm wrong) its antiderivative is given by $$
F(x)=\begin{cases}
\tfrac12x^2+c_1 & \text{if } x\in(0,1),
\\ x+c_2 & \text{if } x\in[1,2),
\\ 3x-\tfrac12x^2+c_3 & \text{if } x\in[2,3),
\end{cases}
$$

where $c_1$, $c_2$ and $c_3$ are not necessarily equal (right?). So my question is, the antiderivative of a piecewise continuous function is not necessarily continuous, right? That would depend on the specific values of $c_1$, $c_2$ and $c_3$, right? So for example $F(x)$ with $c_1=1$, $c_2=-20$, $c_3=0$ should be a not continuous antiderivative of $f(x)$, or should I choose $c_1$, $c_2$ and $c_3$ such that they make $F(x)$ continuous? If the answer is that I have to choose $c_1$, $c_2$ and $c_3$ so that $F(x)$ is continuous, what if $f(x)$ wasn't continuous in the first place, then can I choose them to be different? In that case, would $F(x)$ still be an antiderivative?

Best Answer

If you want $F$ to be an antiderivative on $(0,3)$, then it has to be continuous (and actually differentiable) at $1$ and $2$. This means that once you choose $c_1$, you would be forced to choose a particular $c_2, c_3$ to make the functions values (and derivatives) match from the left and right at $x=1$ and $x=2$.

If you don't pick the $c_1, c_2, c_3$ consistently, you won't have $F'(1)=f(1)$ and $F'(2)=f(2)$, and $F$ won't be an antiderivative of $f$ on $(0,3)$. It will only be an antiderivative of $f$ on $(0,1)\cup(1,2)\cup (2,3)$.