Let's consider the family of sequences of coefficients in the expansion $$\prod_{i=0}^{n-1}(1+x^{3^i}+x^{3^{i+1}})=\sum_{k\geq0}a_n(k)\, x^k.$$
Remark. Evidently, the RHS is a finite sum.
Here is a numerical coincidence for which I ask a direct connection as to why?
QUESTION. It is possible to offer say a recurrence for both sides as to why it is so but is there a more direct connection between the two sides? $$\prod_{k=1}^n\left(4+2\cos\left(\frac{2\pi k}{2n+1}\right)\right) =\sum_{k\geq0}a_n(k)^2.$$