vignettes/getting-started.Rmd
getting-started.Rmd
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.
eq <- "x^2 + 4 + 2*x + 2*x"
yacas(eq)
## yacas_expression(x^2 + 2 * x + 2 * x + 4)
## yacas_expression(x^2 + 4 * x + 4)
## yacas_expression((x + 2)^2)
Or by using the corresponding R
functions directly:
## yacas_expression(x^2 + 4 * x + 4)
## yacas_expression((x + 2)^2)
Or course the result can be saved before calling the helper
R
functions:
## 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}\).
Sym()
## 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}"