ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 28 May 2021 09:55:04 +0200unique elements in complex numbers listhttps://ask.sagemath.org/question/57315/unique-elements-in-complex-numbers-list/I have a list of complex numbers, but even after converting it to a set, there are a lot of repetitions.
here is a minimal example (in my code i have 10^6 polynomials, here only 2)
from sage.rings.polynomial.complex_roots import complex_roots
x = polygen(ZZ)
r1 = complex_roots( x^3+1)
r2 = complex_roots( x^6+2*x^3+1)
s1 = set([r[0] for r in r1])
s2 = set([r[0] for r in r2])
s1 | s2
which results in
{-1,
0.500000000000000? - 0.866025403784439?*I,
0.500000000000000? - 0.866025403784439?*I,
0.500000000000000? + 0.866025403784439?*I,
0.500000000000000? + 0.866025403784439?*I}
as you can see, the roots must be only 3.
Is there an instruction to reduce a set of complex numbers differing less than a delta?alvaroFri, 28 May 2021 09:55:04 +0200https://ask.sagemath.org/question/57315/