Roots of Polynomials

Given a polynomial over GF(p), the gfroots function finds the roots of the polynomial in a suitable extension field GF(pm). There are two ways to tell MATLAB the degree m of the extension field GF(pm), as shown in the table below.

Formats for Second Argument of gfroots

Second ArgumentRepresents
A positive integer m as in GF(pm). MATLAB uses the default primitive polynomial in its computations.
A row vector A primitive polynomial for GF(pm). Here m is the degree of this primitive polynomial.

Example: Roots of a Polynomial in GF(9)

The code below finds roots of the polynomial 1 + x2 +x3 in GF(9) and then checks that they are indeed roots. The exponential format of elements of GF(9) is used throughout.

p = 3; m = 2;
field = gftuple([-1:p^m-2]',m,p); % List of all elements of GF(9)
% Use default primitive polynomial here.
polynomial = [1 0 1 1]; % 1 + x^2 + x^3
rts =gfroots(polynomial,m,p) % Find roots in exponential format
% Check that each one is actually a root.
for ii = 1:3
   root = rts(ii);
   rootsquared = gfmul(root,root,field);
   rootcubed = gfmul(root,rootsquared,field);
   answer(ii)= gfadd(gfadd(0,rootsquared,field),rootcubed,field);
   % Recall that 1 is really alpha to the zero power.
   % If answer = -Inf, then the variable root represents
   % a root of the polynomial.
end
answer

The output shows that A0 (which equals 1), A5, and A7 are roots.

roots =

     0
     5
     7


answer =

  -Inf  -Inf  -Inf

See the reference page for gfroots to see how gfroots can also provide you with the polynomial formats of the roots and the list of all elements of the field.


© 1994-2005 The MathWorks, Inc.