freealg | R Documentation |

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

objects

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)

`words` |
Terms of the algebra object, eg |

`coeffs` |
Numeric vector corresponding to the coefficients of each
element of the |

`string` |
Character string |

`ch` |
Character vector |

`v` |
Vector of integers |

`x` |
Object possibly of class |

`...` |
Further arguments, passed to the methods |

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:

> 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.

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.

Internally, the package uses signed integers and as such can have
`.Machine$integer.max`

different symbols; on my machine this is
2147483647. Of course the print method cannot deal with this as it
only has 26 symbols for letters a-z (and A-Z for the inverses), but
the objects themselves do not care about the print method. Note also
that the experimental calculus facility (as per `deriv()`

)
reserves numbers in the range `SHRT_MAX`

\mjeqn\pm r+/-r for
infinitesimals, where `r`

is the integer for a symbol. This
system might change in the future.

Robin K. S. Hankin

freealg(list(1:2, 2:1,numeric(0),1:6),1:4) 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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.