# freealg: The free algebra In freealg: The Free Algebra

## Description

Create, test for, and coerce to, `freealg` objects

## Usage

 ```1 2 3 4 5 6 7 8``` ```freealg(words, coeffs) is_ok_free(words,coeffs) is.freealg(x) as.freealg(x,...) char_to_freealg(ch) natural_char_to_freealg(string) string_to_freealg(string) vector_to_free(v,coeffs) ```

## Arguments

 `words` Terms of the algebra object, eg `c(1,2,-1,-3,-2)` corresponds to `abACB` because a=1, b=2 etc; uppercase, or negative number, means inverse `coeffs` Numeric vector corresponding to the coefficients of each element of the `word` list `string` Character string `ch` Character vector `v` Vector of integers `x` Object possibly of class `freealg` `...` Further arguments, passed to the methods

## Details

Function `freealg()` is the formal creation mechanism for `freealg` objects. However, it is not very user-friendly; it is better to use `as.freealg()` in day-to-day use.

Function `is_ok_freealg()` checks for consistency of its arguments.

A `freealg` object is a two-element list. The first element is a list of integer vectors representing the indices and the second is a numeric vector of coefficients. Thus, for example:

 ```1 2 3 4 5 6``` ```> as.freealg("a+4bd+3abbbbc") free algebra element algebraically equal to + 1*a + 3*abbbbc + 4*bd > dput(as.freealg("a+4bd+3abbbbc")) structure(list(indices = list(1L, c(1L, 2L, 2L, 2L, 2L, 3L), c(2L, 4L)), coeffs = c(1, 3, 4)), class = "freealg") ```

Observe that the order of the terms is not preserved and indeed is undefined (implementation-specific). Zero entries are stripped out.

Character strings may be coerced to `freealg` objects; `as.freealg()` calls `natural_char_to_freealg()`, which is user-friendly. Functions `char_to_freealg()` and `string_to_freealg()` are low-level helper functions. These functions assume that upper-case letters are the multiplicative inverses of the lower-case equivalents; so for example `as.freealg("aA")` and `as.freealg(aBcCbA)` evaluate to one. This can be confusing with the default print method.

Note carefully that even though individual symbols have multiplicative inverses, a general element of the free algebra will not have a multiplicative inverse. For example, `1+x` does not have an inverse. The free algebra is not a division algebra, in general.

## Author(s)

Robin K. S. Hankin

## Examples

 ```1 2 3 4 5 6``` ```freealg(sapply(1:5,seq_len),1:5) freealg(replicate(5,sample(-5:5,rgeom(1,1/5),replace=TRUE)),1:5) as.freealg("1+xaX")^5 ```

freealg documentation built on Nov. 19, 2021, 9:07 a.m.