gf(2) Berlekamp Algorithm

If possible, factor polynomial, including at least one irreducible factor.

f = b0000000000000000000000000000000000000000000000000000011111011101
f = 0x00000000000007dd
f = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

Calculate vn = x2n (mod f) for n=0 to 10

v0 = x0 (mod f)
v0 = b00000000000000000000000000000001
v0 = 0x00000001
v0 = 1

v1 = x2 (mod f)
v1 = b00000000000000000000000000000100
v1 = 0x00000004
v1 = x2

v2 = x4 (mod f)
v2 = b00000000000000000000000000010000
v2 = 0x00000010
v2 = x4

v3 = x6 (mod f)
v3 = b00000000000000000000000001000000
v3 = 0x00000040
v3 = x6

v4 = x8 (mod f)
v4 = b00000000000000000000000100000000
v4 = 0x00000100
v4 = x8

v5 = x10 (mod f)
v5 = b00000000000000000000001111011101
v5 = 0x000003dd
v5 = x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

v6 = x12 (mod f)
v6 = b00000000000000000000000011001110
v6 = 0x000000ce
v6 = x7 + x6 + x3 + x2 + x

v7 = x14 (mod f)
v7 = b00000000000000000000001100111000
v7 = 0x00000338
v7 = x9 + x8 + x5 + x4 + x3

v8 = x16 (mod f)
v8 = b00000000000000000000001101011010
v8 = 0x0000035a
v8 = x9 + x8 + x6 + x4 + x3 + x

v9 = x18 (mod f)
v9 = b00000000000000000000001011010010
v9 = 0x000002d2
v9 = x9 + x7 + x6 + x4 + x

Represent v0-v9 as matrix Q
Q = 0000000001 0000000100 0000010000 0001000000 0100000000 1111011101 0011001110 1100111000 1101011010 1011010010
Represent 10x10 identity matrix I
I = 0000000001 0000000010 0000000100 0000001000 0000010000 0000100000 0001000000 0010000000 0100000000 1000000000
M = Q-I
M = 0000000000 0000000110 0000010100 0001001000 0100010000 1111111101 0010001110 1110111000 1001011010 0011010010
Find null basis vectors of M

nv0 = b00000000000000000000001001001100
nv0 = 0x0000024c
nv0 = x9 + x6 + x3 + x2

nv1 = b00000000000000000000000000000001
nv1 = 0x00000001
nv1 = 1

Add f to list of known factors (kf)

kfo = b0000000000000000000000000000000000000000000000000000011111011101
kfo = 0x00000000000007dd
kfo = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

For each null basis vector (excluding trivial 1), find known factor (kf) which can be factored.

nv0 = b0000000000000000000000000000000000000000000000000000001001001100
nv0 = 0x000000000000024c
nv0 = x9 + x6 + x3 + x2

New factor (nf) = f/gcd(f,nv0)

nf = b0000000000000000000000000000000000000000000000000000000000110111
nf = 0x0000000000000037
nf = x5 + x4 + x2 + x + 1

Search though known factors (kf) for which (nf) factors evenly

kf0 = b0000000000000000000000000000000000000000000000000000011111011101
kf0 = 0x00000000000007dd
kf0 = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

t = kf0/nf

tremainder = b0000000000000000000000000000000000000000000000000000000000000000
tremainder = 0x0000000000000000
tremainder = 0

tremainder == 0, nf is a factor of kf0

kf0 = nf // Replace kf0 with nf
kf1 = tquotient // Append tquotient to known factors list

tquotient = b0000000000000000000000000000000000000000000000000000000000101111
tquotient = 0x000000000000002f
tquotient = x5 + x3 + x2 + x + 1

Known factors:

kf0 = b0000000000000000000000000000000000000000000000000000000000110111
kf0 = 0x0000000000000037
kf0 = x5 + x4 + x2 + x + 1

kf1 = b0000000000000000000000000000000000000000000000000000000000101111
kf1 = 0x000000000000002f
kf1 = x5 + x3 + x2 + x + 1

Current factorization of f:

f = (b110111)(b101111)
f = (0x37)(0x2f)
f = (x5 + x4 + x2 + x + 1)(x5 + x3 + x2 + x + 1)

See also: