# Largest number of possible real values $x$ where $G(x)$ vanishes?

I'm having trouble with the following question:

Let $g(x)$ be a real valued function defined everywhere on $\Bbb R$. Suppose there are $k \in \Bbb N$ points $x_1, \cdots, x_k$ that are zeros of $g$. Let $G(x)$ be an antiderivative of $g$. What is the largest number of possible real values $x$ such that $G(x) = 0$?

I believe the answer is $k+1$. Here's my reasoning: Consider the graph of $G(x)$. We're trying to maximize the number of zeros of $G$, i.e. the number of times its graph crosses the $x$ axis. Since its derivative $g$ has $k$ zeros, in the "best case" scenario, these zeros correspond to alternating minima and maxima. So order the zeros $x_1 \leq \cdots x_k$ and say that WLOG $x_1$ is at a local minimum of $G$, $x_2$ a local maximum, etc. Furthermore in the "best case" scenario, we can assume that all the minima are negative and all the maxima are positive. Then by the mean value theorem $G$ has exactly one zero between each pair of zeros. This gives us $k-1$ zeros. Also $G$ has two more zeros $x< x_1$ and $x>x_k$ that eventually show up in a best case scenario. In total, this is $\boxed{k+1}$ zeros in the best case scenario.

Is there a way to formalize this argument / a more elegant approach?

Fix some $n \ge 2$, and suppose that $G$ has exactly $n+1$ zeroes $x_0 < \cdots < x_n$. For all $i=1 , \dots ,n$ you have $$G(x_{i-1})=0=G(x_i)$$
hence, by Rolle's theorem there exist $y_i \in (x_{i-1} , x_i)$ such that $G'(y_i)=0$. But $g(y_i)=G'(y_i)$, so that $g$ has at least $n$ zeroes.
By hypothesis you have $n \le k$, so that $G$ has at most $k+1$ zeroes.