**Algebra Packages**

Mathematica provides many functions for working with polynomials, and the standard add-on Algebra packages extend that capability. There are functions for solving polynomial inequalities, counting and isolating roots of polynomials, and representing polynomials in terms of symmetric and remainder parts. The Algebra packages define PolynomialExtendedGCD and PolynomialPowerMod, adjuncts to the built-in functions PolynomialGCD and PolynomialMod. This group of packages also provides functions for manipulating quaternions and elements of Galois fields.

This initializes the Algebra packages.
In[1]:= **<<Algebra`**

Define to be a fifth-degree polynomial in

.
In[2]:= **p = Expand[Product[x-j, {j, 5}]]**

Out[2]=

InequalitySolve gives a logical expression representing the solution to this polynomial inequality.
In[3]:= **InequalitySolve[p < 0, x]**

Out[3]=

SemialgebraicComponents gives a point in each connected component of the inequality solution set.
In[4]:= **SemialgebraicComponents[p < 0, x]**

Out[4]=

Here CountRoots gives the number of roots of in the interval

.
In[5]:= **CountRoots[p, {x, 2.5, 4.5}]**

Out[5]=

Quaternion numbers a+Ib+Jc+Kd, denoted by Quaternion[a,b,c,d], are an extension of the complex numbers a+Ib.

First load the function ListPlotVectorField3D for visualizing vector fields in three dimensions.
In[6]:= **<<Graphics`PlotField3D`**

Consider a set of 27 quaternions, each with a zero real part. This shows how the nonreal part of a quaternion from this set maps into the nonreal part of quaternion

.
In[7]:= **ListPlotVectorField3D[**

Flatten[

Table[ {{b, c, d},

Apply[List, Rest[ Exp[Quaternion[0, b, c, d]] ]]},

{b, 1, 3}, {c, 1, 3}, {d, 1, 3}], 2],

VectorHeads->True, ScaleFactor->.5]

The FiniteFields package can be used to explore error-correcting codes for digital transmission and storage, and other applications of Galois sequences. For example, the Simplex Code based on , a finite field of order , has efficiency and detects errors per codeword of length

.

This gives the Galois sequence for

.
In[8]:= **sequence = First[Transpose[PowerList[GF[2, 4]]]]**

Out[8]=

This depicts the 15 codewords, each composed of four information bits and 11 check bits. Binary ones appear as white squares and binary zeros appear as black squares.
In[9]:= **(codewords = Table[RotateRight[sequence, n],**

{n, 0, 14}];

ListDensityPlot[codewords,

FrameTicks -> {{4, 15}, Range[15]}])

Here are the codewords after transmission through a channel that "flips" each bit with a probability of 0.25. Bits that differ from the original codewords are shaded gray.
In[10]:= **(received = Map[If[Random[] < .25, Mod[#+1, 2], #]&,**

codewords, {2}];

delta = Abs[received-codewords];

ListDensityPlot[Table[If[delta[[i, j]] == 1,

.5, codewords[[i, j]] ], {i, 15}, {j, 15}],

FrameTicks -> {{4, 15}, Range[15]}])

Decoding is accomplished by correlating each received word with the original sequence and finding the position of the peak.
In[11]:= **decode[x_] := Module[{corr},**

corr = Table[Apply[Plus, (1-2 sequence) *

RotateLeft[1-2 x, n]], {n, 0, 14}];

codewords[[ Position[corr, Max[corr]][[1, 1]] ]] ]

Three received words were incorrectly decoded. Two words had four bits in error and one had six bits in error.
In[12]:= **(corrected = Map[decode, received];**

delta = Abs[corrected-codewords];

ListDensityPlot[Table[If[delta[[i, j]] == 1,

.5, codewords[[i, j]] ], {i, 15}, {j, 15}],

FrameTicks -> {{4, 15}, Range[15]}])