Random elements of the free algebra, intended as quick “get you going” examples of freealg objects

rfalg(n=7, distinct=3, maxsize=4, include.negative=FALSE)
rfalgg(n=30, distinct=8, maxsize=7, include.negative=FALSE)
rfalggg(n=100, distinct=26, maxsize=30, include.negative=FALSE)

Arguments

n

Number of terms to generate

distinct

Number of distinct symbols to use

maxsize

Maximum number of symbols in any word

include.negative

Boolean, with default FALSE meaning to use only positive symbols (lower-case letters) and TRUE meaning to use upper-case letters as well, corresponding to the inverse of the lower-case symbols

Details

What you see is what you get, basically. A term such as aaBaAbaC will be simplified to aaaC.

Functions rfalgg() and rfalggg() return successively more complicated freealg objects.

Author

Robin K. S. Hankin

Examples

rfalg()
#> free algebra element algebraically equal to
#> + 9a + 11ba + 4bbaa + 4cb
rfalg(include.negative=TRUE)^2
#> free algebra element algebraically equal to
#> + 16CBCB + 24CBCAAA + 28CBBCbC + 4CBBB + 8CBBaaB + 20CBA + 12CBAcAB + 24CAAACB
#> + 36CAAACAAA + 42CAAABCbC + 6CAAABB + 12CAAABaaB + 30CAAAA + 18CAAAAcAB +
#> 28BCbCCB + 42BCbCCAAA + 49BCbCBCbC + 7BCbCBB + 14BCbCBaaB + 35BCbCA +
#> 21BCbCAcAB + 4BBCB + 6BBCAAA + 7BBBCbC + BBBB + 2BBBaaB + 5BBA + 3BBAcAB +
#> 8BaaBCB + 12BaaBCAAA + 14BaaBBCbC + 2BaaBBB + 4BaaBBaaB + 10BaaBA + 6BaaBAcAB +
#> 20ACB + 30ACAAA + 35ABCbC + 5ABB + 10ABaaB + 25AA + 15AAcAB + 12AcABCB +
#> 18AcABCAAA + 21AcABBCbC + 3AcABBB + 6AcABBaaB + 15AcABA + 9AcABAcAB


constant(rfalg())
#> [1] 0