Learn R Programming

The free group in R

Overview

The freegroup package provides functionality for working with the free group in R. A detailed vignette is provided in the package. Informally, the free group is the set of words that are objects like , with a group operation of string juxtaposition. Usually one works only with words that are in ``reduced form’’, which has successive powers of the same symbol combined, so would be equal to ; see how appears to the third power and the term in the middle has vanished.

The group operation of juxtaposition is formally indicated by , but this is often omitted in algebraic notation; thus, for example .

Installation

You can install the released version of freegroup from CRAN with:

# install.packages("freegroup")  # uncomment this to install the package
library("freegroup")

The freegroup package in use

Function rfree() generates a vector of random free group elements, giving quick “get you going” examples:

a <- rfree(10,5)
a
#>  [1] a.d^5.a^-4.b^5.e^-3 a.e^2.b^2           a^3.e^-7.b^-3      
#>  [4] b^7.d^4             a^2.b^-4.c^-4       a^-5.d^3.c^3       
#>  [7] d^-5.e^-1.d^-5.e^3  c.b^-7.c^4.b^-5     c^6.e^2            
#> [10] e^-3.d^5.a^-5
b <- as.free('x')

Then we can perform various operations on these vectors:

a+b
#>  [1] a.d^5.a^-4.b^5.e^-3.x a.e^2.b^2.x           a^3.e^-7.b^-3.x      
#>  [4] b^7.d^4.x             a^2.b^-4.c^-4.x       a^-5.d^3.c^3.x       
#>  [7] d^-5.e^-1.d^-5.e^3.x  c.b^-7.c^4.b^-5.x     c^6.e^2.x            
#> [10] e^-3.d^5.a^-5.x
a-b
#>  [1] a.d^5.a^-4.b^5.e^-3.x^-1 a.e^2.b^2.x^-1           a^3.e^-7.b^-3.x^-1      
#>  [4] b^7.d^4.x^-1             a^2.b^-4.c^-4.x^-1       a^-5.d^3.c^3.x^-1       
#>  [7] d^-5.e^-1.d^-5.e^3.x^-1  c.b^-7.c^4.b^-5.x^-1     c^6.e^2.x^-1            
#> [10] e^-3.d^5.a^-5.x^-1
a^b
#>  [1] x^-1.a.d^5.a^-4.b^5.e^-3.x x^-1.a.e^2.b^2.x          
#>  [3] x^-1.a^3.e^-7.b^-3.x       x^-1.b^7.d^4.x            
#>  [5] x^-1.a^2.b^-4.c^-4.x       x^-1.a^-5.d^3.c^3.x       
#>  [7] x^-1.d^-5.e^-1.d^-5.e^3.x  x^-1.c.b^-7.c^4.b^-5.x    
#>  [9] x^-1.c^6.e^2.x             x^-1.e^-3.d^5.a^-5.x

There are a number of package functions that work in a vectorized way:

sum(a)
#> [1] a.d^5.a^-4.b^5.e^-3.a.e^2.b^2.a^3.e^-7.b^4.d^4.a^2.b^-4.c^-4.a^-5.d^3.c^3.d^-5.e^-1.d^-5.e^3.c.b^-7.c^4.b^-5.c^6.e^-1.d^5.a^-5

The package also supports extraction and replacement:

a[3:9] <- as.free('xy')
a
#>  [1] a.d^5.a^-4.b^5.e^-3 a.e^2.b^2           x.y                
#>  [4] x.y                 x.y                 x.y                
#>  [7] x.y                 x.y                 x.y                
#> [10] e^-3.d^5.a^-5

Various simple elements can be created:

alpha(1:10)
#>  [1] a b c d e f g h i j
abc(1:5)
#> [1] a         a.b       a.b.c     a.b.c.d   a.b.c.d.e

References

Further information

For more detail, see the package vignette

vignette("freegroup")

Copy Link

Version

Install

install.packages('freegroup')

Monthly Downloads

418

Version

1.2-0

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Robin K S Hankin

Last Published

March 20th, 2025

Functions in freegroup (1.2-0)

tietze

Tietze form for free group objects
identity

The identity element
primitive

Primitive elements of the free algebra
nielsen

Outer automorphisms of the free group
rfree

Random free objects
donames

Names attributes of free group elements
freegroup-package

tools:::Rd_package_title("freegroup")
reduce

Reduction of a word to reduced form
shift

Permute elements of a vector in a cycle
subs

Substitute and invert symbols
sum

Repeated summation by concatenation
dot-class

Class “dot”
size

Bignesses of a free object
backwards

Write free objects backwards
cycred

Cyclic reductions of a word
cumsum

Cumulative sum
abs.free

Absolute value of a free object
alpha

Alphabetical free group elements
abelianize

Abelianization of free group elements
char_to_free

Convert character vectors to free objects
c

Concatenation of free objects
Extract

Extract or replace parts of a free group object
Ops.free

Arithmetic Ops methods for the free group
free

Objects of class free
keep

Keep or drop symbols
getlet

Get letters of a freegroup object
print

Print free objects