I have a list of complex numbers, but even after converting it to a set, there are a lot of repetitions.
Is there an instruction to have only unique elements with complex numbers?
1 | initial version |
I have a list of complex numbers, but even after converting it to a set, there are a lot of repetitions.
Is there an instruction to have only unique elements with complex numbers?
I have a list of complex numbers, but even after converting it to a set, there are a lot of repetitions.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+2x^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 have only unique elements with complex numbers?
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+2x^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 have only unique elements with reduce a set of complex numbers?numbers differing less than a delta?
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+2x^3+1)
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?