# Function to polynomial equation in GF(2)

Let F(a,b,c,d,e) be a function that returns the ith bit of 0x3A5C742E, where i=a*2^4+b*2^3+c*2^2+d*2+e and i is the offset from the least significant bit. The author Page 33/200, chapter 2.3.4 states that in order to find the polynomial for the equivalent output you can use k-maps. Later he states that the equation after the calculations is:

NLF(a,b,c,d,e) = d+e+ac+ae+bc+be+cd+de+ade+ace+abd+abc

Here is my k-map calculation:

     00   01   11   10
000   0    1    1    1
001   0    1    0    0
011   1    1    0    1
010   0    0    0    1
110   0    1    1    0
111   1    1    0    0
101   1    0    0    1
100   0    0    1    1


Where rows are abc, and columns are de

Now from this figure I cannot see how it is possible to generate the given equation. There are elimination of only 1 variable. So all the generated equations should have been at least of 4 degree.

So the question is, how is his equation generated?

The formula $$d+e+ac+ae+bc+be+cd+de+ade+ace+abd+abc$$ is in algebraic normal form (ANF). That is the unique representation of our boolean function with respect to the $\mathbb F_2$-basis $\{a^ib^jc^kd^le^m\mid i,j,k,l,m\in\{0,1\}\}$ of the space of boolean functions $\mathbb F_2^5\to\mathbb F_2$. In particular, note "$+$" is exclusive or.
I do not think the Karnaugh map is very helpful in that case, since grouping the $1$ entries in the table becomes a bit tricky, and since you have to avoid negations. In the end, it works, but it's more involved than just drawing a few rectangles and reading off the right terms.
Instead, the algebraic description above provides an easy iterative method to compute the ANF. (See also this Math.SE post.) Basically, the ANF for our function $f$ will look like this: $$f(a,b,c,d,e) = x_0+ x_aa+x_bb+x_cc+x_dd+x_ee+ x_{ab}ab+x_{ac}ac+x_{ad}ad+x_{ae}ae+x_{bc}bc+x_{bd}bd+x_{be}be+x_{cd}cd+x_{ce}ce+x_{de}de+ x_{abc}abc+x_{abd}abd+x_{abe}abe+x_{acd}acd+x_{ace}ace+x_{ade}ade+x_{bcd}bcd+x_{bce}bce+x_{bde}bde+x_{cde}cde+ x_{abcd}abcd+x_{abce}abce+x_{abde}abde+x_{acde}acde+x_{bcde}bcde+ x_{abcde}abcde \text,$$ and we are interested in computing the unique coefficients $x_\ast\in\{0,1\}$. To do so, we restrict the target function $f$: Setting enough variables to zero will simplify the above formula sufficiently to fully determine another coefficient.
• To start with, we consider the "restriction" $f(0,0,0,0,0)$. By the above formula, this is just $x_0$.
• Next, we consider $f(a,0,0,0,0)=x_0+x_aa$: Since $x_0$ is already known, $x_a$ may be recovered as $f(1,0,0,0,0)+x_0$ (modulo $2$ of course). The coefficients $x_b$ through $x_e$ are computed analogously.
• For $x_{ab}$, consider $f(a,b,0,0,0)=x_0+x_aa+x_bb+x_{ab}ab$: The coefficients $x_0$, $x_a$ and $x_b$ are already known, so we can compute $x_{ab}=f(1,1,0,0,0)+x_0+x_a+x_b$. Again, $x_{ac}$ through $x_{de}$ work exactly the same.