K. = CyclotomicField(17) sqrt17 = sum([(-1)^i*omega^(3^i) for i in range(16)]) sub2 = [sum([(-1)^i*omega^(3^j*9^i) for i in range(8)]) for j in range(2)] sub4 = [sum([(-1)^i*omega^(3^j*13^i) for i in range(4)]) for j in range(4)] sub8 = [sum([(-1)^i*omega^(3^j*16^i) for i in range(2)]) for j in range(8)] nice_basis = [1, sqrt17] + sub2 + sub4 + sub8 for i in range(16): z = CC(nice_basis[i]) if z.real_part()<=-0.0001 or (abs(z.real_part())<0.0001 and z.imag_part()<0): nice_basis[i] = -nice_basis[i] sub2 = nice_basis[2:4] sub4 = nice_basis[4:8] sub8 = nice_basis[8:16] m = Matrix(QQ, 16, 16, [(QQ^16)((omega.coordinates_in_terms_of_powers())(x)) for x in nice_basis]) def on_nice_basis(x): return (QQ^16)((omega.coordinates_in_terms_of_powers())(x)) * m.inverse() symbolic_sqrt17 = sqrt(17) symbolic_basis = [1, symbolic_sqrt17] def symbolicize(x): v = on_nice_basis(x) return sum([v[i]*symbolic_basis[i] for i in range(16) if v[i]!=0]) symbolic_sub2 = [sqrt(symbolicize(x^2)) for x in sub2] symbolic_basis = symbolic_basis + symbolic_sub2 symbolic_sub4 = [sqrt(symbolicize(x^2)) for x in sub4] symbolic_basis = symbolic_basis + symbolic_sub4 symbolic_sub8 = [sqrt(symbolicize(x^2)) for x in sub8] symbolic_basis = symbolic_basis + symbolic_sub8 symbolic_cos = symbolicize((omega+omega^-1)/2) symbolic_omega = symbolicize(omega)