The dot object is defined so that .[x,y] returns the commutator of x and y, that is, xy-yx or the Lie bracket \([x,y]\). It would have been nice to use [x,y] (that is, without the dot) but although this is syntactically consistent, it cannot be done in R.

The “meat” of the dot functionality is:


setClass("dot", slots = c(ignore='numeric'))
`.` <- new("dot")
setMethod("[",signature(x="dot",i="ANY",j="ANY"),function(x,i,j,drop){i*j-j*i})

The package code includes other bits and pieces such as informative error messages for idiom such as .[]. The package defines a matrix method for the dot object. This is because “*” returns (incorrectly, in my view) the elementwise product, not the matrix product.

The Jacobi identity, satisfied by any associative algebra, is

$$ \left[x,\left[y,z\right]\right]+ \left[y,\left[z,x\right]\right]+ \left[z,\left[x,y\right]\right]=0 $$

and the left hand side is returned by jacobi(), which should be zero (for some definition of “zero”).

Function ad() returns the adjoint operator. The adjoint vignette provides details and examples of the adjoint operator.

The dot object is generated by running script inst/dot.Rmd, which includes some further discussion and technical documentation, and creates file dot.rda which resides in the data/ directory.

Slots

ignore:

Object of class "numeric", just a formal placeholder

Methods

[

signature(x = "dot", i = "ANY", j = "ANY"): ...

[

signature(x = "dot", i = "ANY", j = "missing"): ...

[

signature(x = "dot", i = "function", j = "function"): ...

[

signature(x = "dot", i = "matrix", j = "matrix"): ...

[

signature(x = "dot", i = "missing", j = "ANY"): ...

[

signature(x = "dot", i = "missing", j = "missing"): ...

Value

Always returns an object of the same class as xy.

Author

Robin K. S. Hankin

Examples


.[as.freealg("x"),as.freealg("y")]
#> free algebra element algebraically equal to
#> + xy - yx
.[as.freealg("x"),as.freealg("y+2z")]
#> free algebra element algebraically equal to
#> + xy + 2xz - yx - 2zx
.[as.freealg("x+y+2xYx"),as.freealg("x+y+2xYx")]
#> [1] 0


x <- rfalg()
y <- rfalg()
z <- rfalg()

jacobi(x,y,z) # Jacobi identity
#> free algebra element algebraically equal to
#> 0
.[x,.[y,z]] + .[y,.[z,x]] + .[z,.[x,y]]  # Jacobi, expanded
#> free algebra element algebraically equal to
#> 0


f <- ad(x)
f(y)
#> free algebra element algebraically equal to
#> - 25aaabcc - 35aaac + 5aabba - 10aabcb - 15aabcc - 21aac - 15aacbcb + 10abaaa -
#> 5abbaa - 5abbaabcc - 7abbaac - 6abbabc - 2abbabcb - 3abbacbcb + 17abc - 30abca
#> - 30abcabcc - 42abcac - 6abcb - 36abcbc - 12abcbcb + 15abcca + 25abccaa +
#> 5abccabba + 30abccabc + 10abccbaaa + 35abccbc - 18abccbcb + 20abccc + 20ac +
#> 21aca + 35acaa + 7acabba + 42acabc + 14acbaaa + 49acbc - 9acbcb + 28acc -
#> 10baaaa - 10baaaabcc - 14baaaac - 12baaabc - 4baaabcb - 6baaacbcb - 17bca +
#> 30bcaa + 6bcabba + 36bcabc - 35bcabcc - 49bcac + 6bcba + 10bcbaa + 12bcbaaa +
#> 2bcbabba + 12bcbabc + 4bcbbaaa + 14bcbbc + 8bcbc - 14bcbcb + 24bcc - 21bccbcb -
#> 20ca - 20cabcc - 28cac - 24cbc - 8cbcb + 9cbcba + 15cbcbaa + 3cbcbabba +
#> 18cbcbabc + 6cbcbbaaa + 21cbcbbc + 12cbcbc - 12ccbcb


rM <- function(...){matrix(sample(1:9,9),3,3)} # a random matrix

M <- rM()
N <- rM()
O <- rM()

.[M,N]
#>      [,1] [,2] [,3]
#> [1,]  -19  -24   22
#> [2,]   16  -15   26
#> [3,]    8  -15   34
jacobi(M,N,O)
#>      [,1] [,2] [,3]
#> [1,]    0    0    0
#> [2,]    0    0    0
#> [3,]    0    0    0

plot(.[sin,tan](seq(from=0,to=1,len=100)))