2
$\begingroup$

In Root[f,k], how exactly are the roots of a polynomial f enumerated?

The Mathematica manual seems to only say that

The ordering used by Root[f,k] takes real roots to come before complex ones, and takes complex conjugate pairs of roots to be adjacent.

Of course, in general this does not completely determine the ordering/enumeration of the roots.

$\endgroup$
3
  • $\begingroup$ Example of a real numeric root listed $\it{after}$ the numeric complex roots with MMA 12.0. Clear[a, b, c] ; Table[ FullSimplify[ ToRadicals@ Root[ (# - a) (# - b) (# - c) (#^5 + 32) &, k ], {a, b, c} \[Element] Reals], {k, 1, 8} ] Real symbolic roots also come last. $\endgroup$ – LouisB Feb 23 '20 at 21:18
  • $\begingroup$ Strange example with only 3 complex roots (!) and they are sorted out of canonical order in MMA 12.0; Clear[a, b, c]; Table[ ToRadicals @ FullSimplify[ Root[ (# - a) (# - b) (# - c) (#^5 + 32) &, k ], {a, b, c} \[Element] Reals], {k, 1, 8} ] $\endgroup$ – LouisB Feb 23 '20 at 21:25
  • 1
    $\begingroup$ @LouisB - The canonical ordering is done on the raw form, i.e., before you use the functions ToRadicals and FullSimplify. Similarly, Sort does not use N to sort numeric expressions unless you explicitly use SortBy[expr, N] $\endgroup$ – Bob Hanlon Feb 23 '20 at 22:59
4
$\begingroup$
sol = Solve[x^5 + x^3 + 1 == 0, x]

enter image description here

The roots are sorted in canonical order as verified by OrderedQ

OrderedQ@sol

(* True *)

The real roots are first, then the complex roots are sorted first by real part and then by imaginary part.

sol2 = Solve[x^5 + a x^3 + b == 0, x];

Again, the roots are sorted in canonical order

OrderedQ@sol2

(* True *)

Mathematica's canonical order is described in the documentation for Sort

$\endgroup$
1
  • $\begingroup$ Thank you very much! I wish people like you wrote the manual. $\endgroup$ – Iosif Pinelis Feb 24 '20 at 1:04

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.