Nothing
knitr::opts_chunk$set(echo = TRUE)
library(Ryacas0)
Define a character matrix (covariance matrix from a certain $AR(1)$):
N <- 3 L1 <- diag(1, 1 + N) L1[cbind(1+(1:N), 1:N)] <- "-alpha" L1s <- as.Sym(L1) L1s
Now, this can be converted to a Sym
object:
L1s <- as.Sym(L1) L1s
Operations can be performed:
L1s + 4 tmp <- L1s^4 tmp Simplify(tmp)
Or the concentration matrix $K=L L'$ can be found:
K1s <- Simplify(L1s * Transpose(L1s)) K1s
This can be converted to $\LaTeX$:
TeXForm(K1s)
Which look like this:
cat("\\[ K_1 = ", TeXForm(K1s), " \\]", sep = "")
Similar can be done for vectors:
x <- paste0("x", 1:2) xs <- as.Sym(x) xs
And matrix-vector multiplication (or matrix-matrix multiplication):
A <- matrix(paste0(paste0("a", 1:2), rep(1:2, each = 2)), 2, 2) As <- as.Sym(A) As
As*xs As*As
xs Eval(xs, list(x1 = 2, x2 = 3))
As Eval(As, list(a11 = 11, a12 = 12, a21 = 21, a22 = 22))
The functionality can be disabled as follows:
Ryacas_options("module_matvec_enabled") As Ryacas_options(module_matvec_enabled = FALSE) As
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.