TITLE: About the roots of the derivative of a special polynomial
QUESTION [6 upvotes]: Let $p$ be an odd prime, and let $n_1,\dots,n_{p-2}, m$ be even integers such that $n_1 < n_2 < \dots < n_{p-2}$ and
\begin{equation}
2m > \sum_{i=1}^{p-2} n_i^2.
\end{equation}
Consider the polynomial
\begin{equation}
g(x)=(x^2 + m)(x - n_1) \dots (x - n_{p-2}).
\end{equation}
From Rolle's Theorem, we know that for each $i=1,2,\dots,p-3$, there exists $x_i \in (n_i,n_{i+1})$ such that $g'(x_i)=0$. So $g'(x)$ has at least $p-3$ distinct real zeroes. My question is: can $g'(x)$ have more than $p-3$ distinct real zeroes?
I do not know the answer, but for sure the constraints on the parameters are relevant here. For example the polynomial $g(x)=(x^2+1)(x-4)(x-2)(x+2)$ has derivative $g'(x)=5x^4-16x^3-9x^2+24x-4=(x-1)(5x^3-11x^2-20x+4)$ which has four distinct real roots, as you can check on WolframAlpha.
NOTE This strange polynomial arises in the construction given by R. Brauer of a polynomial $f(x) \in \mathbb{Q}[x]$ of degree $p$ whose Galois group over $\mathbb{Q}$ is isomorphic to the symmetric group $\mathcal{S}_p$: see Jacobson, Basic Algebra I, $\S 4.10$. The question I asked is clearly irrelevant for the construction, but has intrigued me, since I could not answer it in the negative nor I could find some counterexample.

REPLY [5 votes]: Expanding $g'(x)$, we have
$$g'(x) = px^{p-1} - (p-1)A x^{p-2} + (p-2)B x^{p-3} + \cdots$$
where $A = \sum\limits_k n_k$ and $B = m + \sum\limits_{i < j}n_in_j$ and indicies $i,j,k$ run over $\{ 1, \ldots, p-2 \}$.
Notice $g'(x)$ is a polynomial with real coefficients and degree $p-1$. If it has more than $p-3$ real roots, then all its roots are real.
By Newton's inequalities, $A$ and $B$ need to satisfy
$$\left(\frac{(p-1)A}{\binom{p-1}{1}}\right)^2 \ge p\frac{(p-2)B}{\binom{p-1}{2}}
\quad\iff\quad A^2 \ge \frac{2p}{p-1}B$$
Substitute above expression of $A, B$ into RHS, the condition can be reexpressed as
$$\begin{align} & (p-1)\left(\sum_k n_k\right)^2 \ge 2p \left(m + \sum_{i<j} n_i n_j\right)\\
\iff & (p-1)\sum_k n_k^2 \ge 2pm + 2\sum_{i<j} n_i n_j\\
\iff & p \sum_k n_k^2 \ge 2pm + \left(\sum_k n_k\right)^2
\end{align}
$$
When $2m > \sum\limits_k n_k^2$, the last condition cannot be satisfied. The coefficients of $g'(x)$ doesn't satisfy Newton's inequalities. As a result, $g'(x)$ has some complex roots. From these, we can conclude

When $2m > \sum\limits_k n_k^2$, $g'(x)$ has at most and hence exactly $p-3$ real roots.