proot and roots with multiplicity

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

proot and roots with multiplicity

Message par jocaps » ven. juin 01, 2018 8:26 pm

Hi,

In giac if I have a polynomial with multiple roots, I also get multiple roots with proot (I cannot rely on root etc. because my polynomials have generally large degrees). This often leads to problem in my program. So I need to convert the output root into a set (python type) or something that will discard the multple root entries in the list. What is the fastest way of doing this? Here is a sample code with proot

Code : Tout sélectionner

from giacpy import proot, giac

x=giac("x")
proot(x**3) #outputs a list [0,0,0], what I want is [0]
set(proot(x**3)) #produces an error because giac gens are not hashable
Any easy way to convert a list of giac (float) gens into a list of python floats? Things could also work if I could convert the giac list to giac set (discarding the repeated 0). It seems that giac set is not included in giacpy.

Edit: I ended up using froot. Because this will just give the multiplicity number (instead of repeated numbers) so instead of [0,0,0] in the above example I would get [0,3]. With this I can just skip the second entry of the list and get the unique roots. Though, I do not know if froot will have any negative effect (e.g. are all (numerical) roots solved up to some precision?)

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re:

Message par parisse » mer. juin 06, 2018 8:29 am

froot does the same as proot in normal precision. Inside giac you can run set[op(proot())] to remove multiplicities.

Répondre