knitr::opts_chunk$set(echo = TRUE)
library(Ryacas0)
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(paste0("Simplify(", eq, ")")) yacas(paste0("Factor(", eq, ")"))
Or by using the corresponding R
functions directly:
Simplify(yacas(eq)) Factor(yacas(eq))
Or course the result can be saved before calling the helper R
functions:
yeq <- yacas(eq) Simplify(yeq) Factor(yeq)
And getting results out:
res <- Factor(yeq) as.character(res) TeXForm(res)
To include inline, e.g. $r TeXForm(yeq)
= r TeXForm(res)
$.
Sym()
xs <- Sym("x") eqs <- xs^2 + 4 + 2*xs + 2*xs Simplify(eqs) Factor(eqs) res <- Factor(eqs) as.character(res) TeXForm(res)
Sym()
yacas("p := x^2 + 4 + 2*x + 2*x") ps <- Sym("p") ps TeXForm(Simplify(ps))
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.