The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Getting started

Mikkel Meyer Andersen and Søren Højsgaard

2023-01-12

library(Ryacas0)

Introduction

Ryacas makes the yacas computer algebra system available from within R. The name yacas is short for “Yet Another Computer Algebra System”. The yacas program is developed by Ayal Pinkhuis (who is also the maintainer) and others, and is available at http://www.yacas.org/ for various platforms. There is a comprehensive documentation (300+ pages) of yacas (also available at http://www.yacas.org/) and the documentation contains many examples.

Example 1: using character vectors

eq <- "x^2 + 4 + 2*x + 2*x"
yacas(eq)
## yacas_expression(x^2 + 2 * x + 2 * x + 4)
yacas(paste0("Simplify(", eq, ")"))
## yacas_expression(x^2 + 4 * x + 4)
yacas(paste0("Factor(", eq, ")"))
## yacas_expression((x + 2)^2)

Or by using the corresponding R functions directly:

Simplify(yacas(eq))
## yacas_expression(x^2 + 4 * x + 4)
Factor(yacas(eq))
## yacas_expression((x + 2)^2)

Or course the result can be saved before calling the helper R functions:

yeq <- yacas(eq)
Simplify(yeq)
## yacas_expression(x^2 + 4 * x + 4)
Factor(yeq)
## yacas_expression((x + 2)^2)

And getting results out:

res <- Factor(yeq)
as.character(res)
## [1] "(x + 2)^2"
TeXForm(res)
## [1] "\\left( x + 2\\right)  ^{2}"

To include inline, e.g. \(x ^{2} + 2 x + 2 x + 4 = \left( x + 2\right) ^{2}\).

Example 2: using Sym()

xs <- Sym("x")
eqs <- xs^2 + 4 + 2*xs + 2*xs
Simplify(eqs)
## yacas_expression(x^2 + 4 * x + 4)
Factor(eqs)
## yacas_expression((x + 2)^2)
res <- Factor(eqs)
as.character(res)
## [1] "(x + 2)^2"
TeXForm(res)
## [1] "\\left( x + 2\\right)  ^{2}"

Example 3: using Yacas variables and Sym()

yacas("p := x^2 + 4 + 2*x + 2*x")
## yacas_expression(x^2 + 2 * x + 2 * x + 4)
ps <- Sym("p")
ps
## yacas_expression(x^2 + 2 * x + 2 * x + 4)
TeXForm(Simplify(ps))
## [1] "x ^{2} + 4 x + 4"

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.