# Coefficients of polynomials forming an unimodal sequence

Let $f(x)=\sum_{i=0}^{n}a_{i}x^{i}$ be a polynomial with rational coefficients. I am interested in an efficient way which allows checking whether the finite sequence $A=(a_{i})_{i\in\{0,\ldots,n\}}$ is unimodal. Let us recall that the sequence is unimodal if there is $k\in\{0,\ldots,n\}$ such that $a_{0}\leq \ldots\leq a_{k-1}\leq a_{k}\geq a_{k+1}\geq \ldots \geq a_{n}$.

• So you want to use the software Mathematica for this? Sep 26, 2017 at 6:08
• @J. M. Yes, I want to use Mathematica for this computation for several values of $n$. Sep 26, 2017 at 11:04
• Would Differences[Sign[Differences[CoefficientList[poly, x]]]] be useful to you? Sep 26, 2017 at 12:07
• The best answer for me would be the information whether the sequence of coefficients is unimodal. Proposed approach gives another sequence of numbers and it is not clear to me how you want to extract the information concerning unimodality. Sep 27, 2017 at 7:48

Diff[f_] := Select[Differences[Sign[Select[

In particular, Sign[Select[Differences[CoefficientList[f, x]], Unequal[#, 0] &]] returns either the empty list (if all numbers are equal) or a list of -1s and 1s in some order depending on whether the corresponding difference was negative or positive. The next application of Select[Differences[...]] then extracts the points in which this sequence changes from 1 to -1 or vice versa. This list is then unimodal if the resulting list is either the empty list (in which case the sequence was monotonic) or {-2} (coming from only 1s followed by only -1s).