The free algebra \(\mathcal B\) is a graded algebra: that is, for each integer \(n\geq 0\) there is a homogeneous subspace \(\mathcal{B}_n\) with \(\mathcal{B}_0=\mathcal{R}\) and

$$ \mathcal{B}=\bigoplus_{n=0}^\infty\mathcal{B}_n,\quad\mbox{and}\quad\mathcal{B}_n\mathcal{B}_m\subseteq\mathcal{B}_{n+m}\quad\mbox{for all $m,n\geq 0.$} $$

The elements of \(\cup_{n\geq 0}\mathcal{B}_n\) are called homogeneous and those of \(\mathcal{B}_n\) are called homogenous of degree (or grade) \(n\).

The grade of a term is the number of symbols in it. Thus the grade of xxx and 4xxy is 3; the grade of a constant is zero. Because the terms are stored in an implementation-specific way, the grade of a multi-term object is a disord object.

The grade of the zero freealg object, grade(as.freealg(0)), is defined to be \(-\infty\), as per Knuth [TAOCP, volume 2, p436]. This ensures that max(grades(abelianize(x))) <= max(grades(x)) is always satisfied. However, a case for NULL could be made.

grades(x)
grade(x,n)
grade(x, n) <- value
deg(x)

Arguments

x

Freealg object

n

Integer vector

value

Replacement value, a numeric vector

Details

grades(x) returns the grade (number of symbols) in each term of a freealg object x.

deg(x) returns the maximum of the grades of each symbol of x; max(grades(x)).

grade(x,n) returns the freealg object comprising terms with grade n (which may be a vector). Note that this function is considerably less efficient than clifford::grade().

grade(x,n) <- value sets the coefficients of terms with grade n. For value, a length-one numeric vector is accepted (notably zero, which kills terms of grade n) and also a freealg object comprising terms of grade n.

Value

Returns a disord object

References

H. Munthe-Kaas and B. Owren 1999. “Computations in a free Lie algebra”, Phil. Trans. R. Soc. Lond. A, 357:957–981 (theorem 3.8)

Author

Robin K. S. Hankin

Note

A similar concept grade is discussed in the clifford package

Examples



X <- as.freealg("1 -x + 5*y + 6*x*y -8*x*x*x*x*y*x")
X
#> free algebra element algebraically equal to
#> + 1 - x - 8xxxxyx + 6xy + 5y
grades(X)
#> A disord object with hash 55749095669cc08d7e66c42699d38acf64666dad and elements
#> [1] 0 1 6 2 1
#> (in some order)

a <- rfalg(30)
a
#> free algebra element algebraically equal to
#> + 7aaaa + 5abc + 10acaa + 102b + 30ba + 23bab + 27bb + 8bbbb + 2bc + 15bccb +
#> 84c + 40ca + 3caac + caba + 20cacc + 26cbca + 39cc + 4ccab + 6ccbb + 13ccca
grades(a)
#> A disord object with hash e5d42ad70181cd4f4c778f7aa1fd4c9711633aa9 and elements
#>  [1] 4 3 4 1 2 3 2 4 2 4 1 2 4 4 4 4 2 4 4 4
#> (in some order)
grade(a,2)
#> free algebra element algebraically equal to
#> + 30ba + 27bb + 2bc + 40ca + 39cc
grade(a,2) <- 0 # kill all grade-2 terms
a
#> free algebra element algebraically equal to
#> + 7aaaa + 5abc + 10acaa + 102b + 23bab + 8bbbb + 15bccb + 84c + 3caac + caba +
#> 20cacc + 26cbca + 4ccab + 6ccbb + 13ccca

grade(a,1) <- grade(a,1) * 888 
a
#> free algebra element algebraically equal to
#> + 7aaaa + 5abc + 10acaa + 90576b + 23bab + 8bbbb + 15bccb + 74592c + 3caac +
#> caba + 20cacc + 26cbca + 4ccab + 6ccbb + 13ccca