In [SageMath](https://sagecell.sagemath.org/), you can enter the following: U.<zeta> = CyclotomicField(43) P.<x> = PolynomialRing(U) def c(j): # cos(j * pi / 43) return (zeta ** j + zeta ** (-j))/2 x1 = 2*(c(2) + c(12) + c(14)) x2 = 2*(c(6) + c(36) + c(42)) x3 = 2*(c(18) + c(22) + c(40)) x4 = 2*(c(20) + c(32) + c(34)) x5 = 2*(c(10) + c(16) + c(26)) x6 = 2*(c(8) + c(30) + c(38)) x7 = 2*(c(4) + c(24) + c(28)) (x-x1)*(x-x2)*(x-x3)*(x-x4)*(x-x5)*(x-x6)*(x-x7) And you get: x^7 + x^6 - 18*x^5 - 35*x^4 + 38*x^3 + 104*x^2 + 7*x - 49 that is: $x^{7} + x^{6} - 18 x^{5} - 35 x^{4} + 38 x^{3} + 104 x^{2} + 7 x - 49$.