I tried to solve a calculation problem and got the correct result, but I don't understand the solution provided at the end of the exercise. Although I got the same answer, I would also like to understand what is happening in the given solution.

Consider the function: $$ f (x) = begin {cases}

x ^ 2 + ax + b & x leq 0 \

x-1 & x> 0 \ end {cases} $$ Find the antiderivatives of the function $ f $ if they exist

The solution provided is more or less like this:

by $ f $ have the function antiderivative $ f $ must have the darboux

property. (… Some calculations …), therefore $ f $ has the darboux

property yes and only yes $ b = -1 $ (I understood that now the function

it is continuous, therefore it has an anitederivativa). Using the

consequences of Lagrange's theorem at intervals $ (- infty, 0) $ Y

$ (0, infty) $ any antiderivative $ F: mathbb {R} rightarrow

mathbb {R} $ from $ f $ It has the form:$$ F (x) = begin {cases}

dfrac {x ^ 3} {3} + a dfrac {x ^ 2} {2} – x + c_1 & x < 0 \ c_2 & x=0 \ dfrac{x^2}{2} - x + c_3 & x>0 end {cases} $$$ F $ being differentiable, it is also continuous, so $ F (0) = c_2 = c_1 =

c_3 $.Therefore, the antiderivatives of $ f $ have the form:

$$ F (x) = c + begin {cases}

dfrac {x ^ 3} {3} + a dfrac {x ^ 2} {2} – x & x leq 0 \

dfrac {x ^ 2} {2} – x & x> 0 end {cases} $$

Again, I got the same result, but I don't understand much of the work done previously.

The first thing I didn't understand is the part where they say that $ f $ It has an antiderivative if it has the Darboux property. I searched a little online and discovered that a function accepts antiderivatives only if it has the Darboux property. So I guess I have to accept that as a fact.

The second (and most important) that I didn't understand was the part where they said they used the consequences of Lagrange's Theorem at intervals. $ (- infty, 0) $ Y $ (0, infty) $ to find that first form of antiderivative. What theorem do they refer to? How did they use it at those intervals? Why is there a separate case for $ x = 0 $ with an additional constant $ c_2 $. I just used $ 2 $ constants, why they were necessary $ 3 $? In a nutshell, I don't understand how they got to that first form of antiderivative and how they used these "consequences of Langrange's theorem." I understood the second form of the antiderivative, that is what I also got, but the first form left me in the dark.

I know these are just details, but I really want to understand what was used here, why it was used and how it was used.