To cite the freealg
package in publications, please use
Hankin (2022b). In this short document
I show how free algebras may be studied using the freealg
package. The free algebra is best introduced by an example:
with an alphabet of {x, y, z}, and
real numbers α, β, γ we
formally define A = αx2yx + βzy
and B = −βzy + γy4.
Addition is commutative so A + B = B + A.
However, multiplication is not commutative so AB ≠ BA
in general; both are associative. We also have consistency in that α(βP) = (αβ)P
for any expression P.
Then:
A + B = (αx2yx + βzy) + (−βzy + γy4) = αx2yx + γy4
AB = (αx2yx + βzy)(−βzy + γy4) = −αβx2yxzy + αγx2yxy4 − β2zyzy + βγzy5
BA = (−βzy + γy4)(αx2yx + βzy) = −αβzyx2yx − β2zyzy + αγy4x2yx + βγy4zy
This is a natural set of objects to consider. Formally, we consider the free R-module with a basis consisting of all words over an alphabet of symbols [conventionally lower-case letters] with multiplication of words defined as concatenation. The system inherits associativity from associativity of concatenation; distributivity follows from the definition of R-module. However, the free algebra is not commutative in general.
freealg
package in useThe above examples are a little too general for the
freealg
package; the idiom requires that we have specific
numerical values for the coefficients α, β, γ. Here we
will use 1, 2, 3 respectively.
## free algebra element algebraically equal to
## + xxyx + 2zy
## free algebra element algebraically equal to
## + 3yyyy - 2zy
## free algebra element algebraically equal to
## + xxyx + 3yyyy
## free algebra element algebraically equal to
## + 3xxyxyyyy - 2xxyxzy + 6zyyyyy - 4zyzy
## free algebra element algebraically equal to
## + 3yyyyxxyx + 6yyyyzy - 2zyxxyx - 4zyzy
Note that the terms are stored in an implementation-specific order.
For example, A
might appear as xxyz + 2*zy
or
the algebraically equivalent form 2*zy + xxyz
. The package
follows disordR
discipline (Hankin 2022a).
Inverses are coded using upper-case letters.
## free algebra element algebraically equal to
## + xxy + 2zyX
See how multiplying by X = x−1 on the
right cancels one of the x
terms in A
. We can
use this device in more complicated examples:
## free algebra element algebraically equal to
## + 3 + 5X - 2Xyx
## free algebra element algebraically equal to
## + 5xxy + 3xxyx - 2xxyyx + 6zy + 10zyX - 4zyXyx
## free algebra element algebraically equal to
## - 2Xyxxxyx - 4Xyxzy + 10Xzy + 3xxyx + 5xyx + 6zy
With these objects we may verify that the distributive and associative laws are true:
## [1] TRUE
## [1] TRUE
## [1] TRUE
Various utilities are included in the package. For example, the commutator bracket is represented by reasonably concise idiom:
## free algebra element algebraically equal to
## + ab - ba
Using rfalg()
to generate random free algebra objects,
we may verify the Jacobi identity:
## free algebra element algebraically equal to
## 0
The package includes functionality for substitution:
## free algebra element algebraically equal to
## + aaccc + 3aaxccc
## free algebra element algebraically equal to
## + 4accc + 3adccc + 6aeccc
It is possible to extract components of freealg
objects
using reasonably standard idiom:
## free algebra element algebraically equal to
## + aaa + 2aaba + 3abbbba - 3abc + 9xyzabc
## free algebra element algebraically equal to
## + 3abbbba + 9xyzabc
## free algebra element algebraically equal to
## + aaa + 2aaba + 3abbbba + 99abc + 9xyzabc
There is even some experimental functionality for calculus:
## free algebra element algebraically equal to
## + aaaxa(da) + aaax(da)a + aa(da)xaa + a(da)axaa + (da)aaxaa
Above, “da
” means the differential of a
.
Note how it may appear at any position in the product, not just the end
(cf matrix differentiation).
disordR
Package.”
arXiv. https://doi.org/10.48550/ARXIV.2210.03856.