Solution (source code)

= Solution

On the <unit circle>, $z^{-1}=\overline z$, so
$$
p(z)=2+z+\overline z=(1+z)(1+\overline z)=|1+z|^2.
$$
Thus the <trigonometric polynomial> is nonnegative, with a zero at $z=-1$, and
$$
\boxed{q(z)=1+z,\qquad p(z)=|q(z)|^2\quad(|z|=1)}.
$$
Equivalently, writing $z=e^{i\theta}$ gives $p(z)=2+2\cos\theta=4\cos^2(\theta/2)$. The factor has <polynomial degree> one as required. Multiplication of $q$ by any constant of modulus one leaves the factorization unchanged; uniqueness of $q$ is not claimed.

This is the simplest instance of the <Fejér–Riesz theorem>, where nonnegativity of a <trigonometric polynomial> on the <unit circle> admits a <polynomial> modulus-square factorization.