# Generating de Bruijn sequences over GF(4)

I'm trying to generate a de Bruijn sequence in GF(4) of order $k$ using the recursive formula from this paper:

$s_i = \theta_{k-1}s_{i-1} + \theta_{k-2}s_{i-2} + \dots + \theta_{0}s_{i-1k}$

where $\sum_{i = 0}^{k-1}{\theta_i x^i}$ is a primitive polynomial.

I came up with a short implementation in Python and as far as I can tell it reflects the model (it works if I generate sequences over GF(2)) but it doesn't generate the desired sequence correctly. What I found a bit suspicious is that the polynomial has degree $k-1$, not $k$ and that $\theta_0$ is multiplied by a sequence element. Should this method work also on GF(4)?

-
I suspect it is the polynomial $x^k - \sum_{i = 0}^{k-1}{\theta_i x^i}$ that should be primitive over $GF(4)$, since that is the characteristic polynomial of the recurrence. (Of course in characteristic 2 there is no difference between $-$ and $+$.) I reckon the paper misquoted the result. – Erick Wong Nov 17 '12 at 17:03
Thank you for the quick reply. Would that mean that $\theta_0$ should be included in the recurrence but not multiplied by a sequence element? – Greg Slodkowicz Nov 17 '12 at 17:10
No, I don't see anything wrong with the term $\theta_0 s_{i-k}$. Perhaps you could clarify what is wrong with the generated sequence and how you selected a primitive polynomial? – Erick Wong Nov 18 '12 at 5:57
you're absolutely right, there is an error in the formula, the first term is missing. – Greg Slodkowicz Nov 18 '12 at 11:56