Sagemath: Factoring an integer inside a ring of integers different from $\mathbb{Z}$

186 Views Asked by At

I am trying to find divisors of an element in the ring of integers of a Cyclotomic Field. My code is

K=CyclotomicField(23)
L=K.ring_of_integers()
L.factor(2)

It gives an error:

'AbsoluteOrder_with_category' object has no attribute 'factor'

I guess the problem is L is defined as an order here. But I need that to be a ring. How can I fix this problem?

1

There are 1 best solutions below

0
dan_fulea On

Let us take some simpler cyclotomic fields first, and factor two in them:

for k in [3..28]:
    F.<u> = CyclotomicField(k)
    if F.class_number() != 1:
        continue
    print(f'k = {k} :: 2 = {factor(F(2))}')

This gives:

k = 3 :: 2 = 2
k = 4 :: 2 = (-u) * (u + 1)^2
k = 5 :: 2 = 2
k = 6 :: 2 = 2
k = 7 :: 2 = (u^4 + u^3 + u^2 + 1) * (u^5 + u^4 + u^3 + 1)
k = 8 :: 2 = (2*u^3 - 3*u^2 + 2*u) * (u + 1)^4
k = 9 :: 2 = 2
k = 10 :: 2 = 2
k = 11 :: 2 = 2
k = 12 :: 2 = (u) * (-u^2 + u + 1)^2
k = 13 :: 2 = 2
k = 14 :: 2 = (u^4 - u^3 + u^2 + 1) * (-u^5 + u^4 - u^3 + 1)
k = 15 :: 2 = (-u^7 + u^5 + u^3 - u^2 + 1) * (-u^7 - u^5 + u^3 - u^2)
k = 16 :: 2 = (-860*u^7 - 658*u^6 + 356*u^5 + 931*u^4 + 356*u^3 - 658*u^2 - 860*u) 
              * (-u^6 + u)^8
k = 17 :: 2 = (-u^4) * (u^14 + u^8 + u^4 + u^3 + u^2 + u) 
              * (2*u^15 + u^14 + u^11 + u^10 + u^7 + 2*u^6 + u^3 + u^2 + u)
k = 18 :: 2 = 2
k = 19 :: 2 = 2
k = 20 :: 2 = (-u^3) * (u^6 + u)^2
k = 21 :: 2 = (-u^11 - u^4) * (u^11 - u^9 + u^4 - u^3 - 1) * (u^8 - u^6 - u^3 + u - 1)
k = 22 :: 2 = 2
k = 24 :: 2 = (-2*u^7 + 2*u^5 + 2*u^3 + 3*u^2) * (u^7 - u^4)^4
k = 25 :: 2 = 2
k = 26 :: 2 = 2
k = 27 :: 2 = 2
k = 28 :: 2 = (-u) * (u^5 - u^4 - 1)^2 * (u^10 + u^9 - u^8 - u^7 + u^6 + u^5 - u^3 + u)^2

(Result was manually adjusted at two places to fit in the page.)

However, the cyclotomic field of order 23 is not a unique factorization domain, so we should factor the corresponding fractional ideal instead:

sage: K.<u> = CyclotomicField(23)
sage: K.class_number()
3
sage: K.fractional_ideal(2).factor()
    (Fractional ideal (2, u^11 + u^9 + u^7 + u^6 + u^5 + u + 1)) *
    (Fractional ideal (2, u^11 + u^10 + u^6 + u^5 + u^4 + u^2 + 1))

(Result was again manually adjusted to fit in the page.)