1
$\begingroup$

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}$.

$\endgroup$
4
  • 1
    $\begingroup$ So you want to use the software Mathematica for this? $\endgroup$ Sep 26, 2017 at 6:08
  • $\begingroup$ @J. M. Yes, I want to use Mathematica for this computation for several values of $n$. $\endgroup$ Sep 26, 2017 at 11:04
  • 1
    $\begingroup$ Would Differences[Sign[Differences[CoefficientList[poly, x]]]] be useful to you? $\endgroup$ Sep 26, 2017 at 12:07
  • $\begingroup$ 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. $\endgroup$ Sep 27, 2017 at 7:48

1 Answer 1

0
$\begingroup$

Very late response, but here's a method to do just that:

Diff[f_] := Select[Differences[Sign[Select[
 Differences[CoefficientList[f, x]], Unequal[#, 0] &]]], Unequal[#, 0] &]

Unimodal[f_] :=
  MemberQ[{{}, {-2}}, Diff[f]]

The idea is similar to JM's response in the above comment, but it removes differences that are equal to zero at two points in the computation.

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).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.