about the proot command output

10052014, 09:39 PM
Post: #1




about the proot command output
Hi,
The proot command in the Prime inputs a list, say p, and outputs a list, proot(p), whose items are the roots of the polynomial whose coefficients are those of the list p, with 1st item in list equal to constant coefficient, and so on. Is there any rule as to how the roots are ordered in the list proot(p)? Sometimes I get real numbers first, sometime complex numbers first. For example, proot([1 2 4 4 5 6])=[3. 1. 2. i i]) proot([1 2 4 4 5 7])=[2.74e2+1.03*i 2.74e21.03*i 1.07 2.01 2.98] Also, related to input, how does the CAS Setting INCREASING affect the order of the input list of coefficients? Thanks 

10062014, 08:17 AM
Post: #2




RE: about the proot command output
proot output is not sorted, run sort(proot(...)) to sort it.
Increasing coeffs flag is for symbolic output only. 1d polynomial input/output as a list of coefficients is sorted from x^n to x^0. 

10062014, 02:18 PM
Post: #3




RE: about the proot command output
(10062014 08:17 AM)parisse Wrote: proot output is not sorted, run sort(proot(...)) to sort it. Thank you. But how does SORT work on a list that has both real and complex numbers? It does sort the real numbers from small to large, but I cannot figure out what it does to the complex ones: SORT([1 i i 3 2+i])=[1 3 2+i i i] Or what it does to lists with just complex numbers SORT([2+i i 2+i 3i 5i]) = [5i 3i 2i 2i i] 

10062014, 03:58 PM
Post: #4




RE: about the proot command output
If you want to sort by real part first then imaginary part, you can try something like:
l:=[2+i, i, 2+i ,3i ,5i]; sort(l,(a,b)>if re(a)!=re(b) then re(a)<re(b) else im(a)<im(b) end); 

10062014, 04:23 PM
Post: #5




RE: about the proot command output
(10062014 03:58 PM)parisse Wrote: If you want to sort by real part first then imaginary part, you can try something like: Great, thanks. I was just reading about SORT with functions in your hprime.pdf, but did not think of this possibility. 

10072014, 07:45 AM
Post: #6




RE: about the proot command output
By the way, in the latest Xcas version you can also use SortA. I don't remember if that works on the Prime.
I'm going to modify proot in Xcas in order to sort the roots. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 3 Guest(s)