K. = CyclotomicField(342) omega = a^18 zeta = a^19 alpha = [sum([zeta^(i*j)*omega^(2^i) for i in range(18)]) for j in range(18)] powtab = [NN(18/gcd(i,18)) for i in range(18)] atab = [alpha[i]^powtab[i] for i in range(18)] atab_on_zeta_basis = [(QQ^6)((zeta.coordinates_in_terms_of_powers())(x)) for x in atab] sqrtm3 = 2*zeta^3-1 nice_basis = [1, sqrtm3, zeta^2, zeta^-2, zeta, zeta^-1] m = Matrix(QQ, 6, 6, [(QQ^6)((zeta.coordinates_in_terms_of_powers())(x)) for x in nice_basis]) atab_on_nice_basis = [v * m.inverse() for v in atab_on_zeta_basis] zetab = [ZZ(floor(arg(CC(N(alpha[i])/N(atab[i]^(1/powtab[i]))))/arg(zeta)+0.5)) for i in range(18)] btab = [zeta^zetab[i] for i in range(18)] btab_on_zeta_basis = [(QQ^6)((zeta.coordinates_in_terms_of_powers())(x)) for x in btab] btab_on_nice_basis = [v * m.inverse() for v in btab_on_zeta_basis] symbolic_basis = [1, sqrt(-3), ((1/2)*(-1+sqrt(-3)))^(1/3), ((1/2)*(-1-sqrt(-3)))^(1/3), ((1/2)*(1+sqrt(-3)))^(1/3), ((1/2)*(1-sqrt(-3)))^(1/3)] symbolic_omega = sum([sum([btab_on_nice_basis[i][j]*symbolic_basis[j] for j in range(6)])*(sum([atab_on_nice_basis[i][j]*symbolic_basis[j] for j in range(6)]))^(1/powtab[i]) for i in range(18)])/18 symbolic_cos = sum([sum([btab_on_nice_basis[i][j]*symbolic_basis[j] for j in range(6)])*(sum([atab_on_nice_basis[i][j]*symbolic_basis[j] for j in range(6)]))^(1/powtab[i]) for i in range(0,18,2)])/18