Ryacas (github project name ryacas) is an R package that allows R users to access the yacas computer algebra system from within R. It can be used for computer algebra, exact arithmetic, ASCII pretty printing and R to TeX output. R, Ryacas and yacas are all free software packages distributed under the GPL and LGPL, respectively. See here or the package vignette for examples of yacas calculations performed from wihin R. Ryacas is available on CRAN now.
Readers should also note the availability of the rSymPy CRAN project which interfaces to the jython version of the sympy computer algebra system. Also rMathpiper provides an R interface to MathPiper (a modified java version of yacas).
NEWS
In addition to the NEWS items below see the NEWS file that comes with Ryacas. It is more focused on changes in the package itself than the news listed here.
- September 14, 2014. A new version, Ryacas 0.2.12.1 has been uploaded. It fixes some problems running under R 3.1 .
- September 7, 2011. A new version, Ryacas 0.2-11, has been added to the repository and uploaded to CRAN. It addresses certain changes that occurred in R 2.14.
- February 5, 2010. A new version, Ryacas 0.2-10, has been added to the repository and uploaded to CRAN. It is a bug fix version.
- October 21, 2009. The java version of yacas project appears to have moved to Mathpiper of the Mathrider project. See announcement here. The STATUS section below has been updated accordingly.
- October 21, 2009. YacasCE (google translation) for the pocket PC (Windows mobile) is available.
- August 23, 2009. It seems that a new release of the XML package has again broken Ryacas. Use XML 2.5.3 or XML 1.9.0 with Ryacas instead.
- July 13/09. It may be that the problem between Ryacas 0.2-9 and XML 2.3-0 (mentioned in news item for Mar 12/09) is resolved by simply using the new release of the XML package, XML 2.5-3 instead of the older versions of the XML package. Will need to check a bit more to be sure.
- Mar 12/09. Just found an incompatibility between Ryacas 0.2-9 and XML 2.3-0. Until this is fixed use Ryacas 0.2-7 and XML 1.96-0. If you are having difficulty with this try the rSymPy package instead.
- Mar 9/09. UNIX/Linux Installation section further down on this page has been rewritten.
- Mar 3/09. Ryacas 0.2-9 is now available on CRAN. Primary change is to require XML 2.1-0 or higher and some fixes to the documentation to pass R CMD CHECK on R 2.9.0. Note that Ryacas seems to work once again with the latest version the XML package, XML 2.1-0. It also worked with XML 1.96-0 but versions of the XML package after XML 1.96-0 but before XML 2.1-0 did not work with Ryacas.
- Dec 21/08. Added Troubleshooting instructions on how to use XML 1.96-0 with Ryacas even if you have a newer version of XML installed at the same time.
- Nov 16/08. In Troubleshooting section below, Ryacas works with XML package version 1.96-0 but not with XML package version 1.98-1.
- May 07/08. In Troubleshooting section below added a tip about deleting .yacCon .
- Feb 04/08. Gregor Gorjanc's blog has an article on how to use Ryacas via Sweave in LyX.
- Oct 17/07. Added an item to the troubleshooting section that Ryacas 0.2-7 has only been tested with yacas 1.0.63. Windows users of Ryacas 0.2-7 will automatically get yacas 1.0.63 if they use the Ryacas yacasInstall() command to install yacas but users on Mac and UNIX platforms currently need to be aware of this so they install yacas 1.0.63 and not a different version of yacas. The SystemRequirements: line of the Ryacas DESCRIPTION file indicates that yacas 1.0.63 or greater should be used; however, versions greater than 1.0.63 have not been tested and so might not work with Ryacas 0.2-7.
- Oct 15/07. Reorganized multiple Installation and multiple Troubleshooting sections (end of this page) into a single section for each with subsections.
- Sep 9/07. Version 0.2-7 of Ryacas uploaded to CRAN. Changes include socket timing improvement in yacas.R suggested by Petr Savicky, a new Encoding: line in DESCRIPTION file to handle R 2.6.0 warnings and several other minor changes to handle R 2.6.0 compatability.
- Aug 19/07. dep=TRUE is the default for install.packages so instructions have been simplified.
- May 13/07. The install.packages('Ryacas', dep = TRUE) command for installing Ryacas on Mac is now the same as on UNIX so the installation sections for Mac and UNIX have been combined into one below.
- May 12/07. Ryacas 0.2-6 now on CRAN. Bug fix version. See NEWS.
- May 5/07. In Links section to right added new link to CRAN. (Removed links to Omegahat and Ryacas Yahoo group since Ryacas distribution is now via CRAN.)
- May 1/07. Ryacas has been uploaded to CRAN. (Previously it was on Omegahat.) Also Ryacas is upgraded to 0.2-5 to accomodate changes in R that were made with R 2.5.0. Earlier versions of R will not work with this version of Ryacas. Note that yacas.exe is no longer included with Ryacas but for Windows users only there does exist a yacasInstall() command that can be issued without arguments from within R to download and install yacas.
- Jan 17/06. Added Wikipedia CAS Comparison to Links section on right.
- Jan 9/06. The Downloads tab above contains yacas 1.0.63 source code in a .tar.gz file as well as the Windows yacas 1.0.63 binaries in a .zip file. yacas.exe and scripts.dat have been removed from the svn repository in preparation for CRAN -- as CRAN packages cannot have binaries in their source :(
- Dec 28/06. Added a note for installing Ryacas under Gentoo on this page in the UNIX TROUBLESHOOTING section below.
- Dec 23/06. The Sample Session formerly on this page has been moved to the Wiki. See Wiki tab above.
- Dec 6/06. The two vignettes are now combined into one. Click on Ryacas - vignette in Links section to right.
- Nov 19/06. The very latest (development) version (to become 0.2-4) is available via svn from the Source tab at top of this page. It is expected that this version will become eventually be available from CRAN. Until then use Ryacas 0.2-3 as in following news items. Anyone who would like to test the development version out, any feedback (to the developers listed under TEAM) would be appreciated.
- Nov 19/06. Ryacas 0.2-3 is now available for download from Omegahat via the install.packages command (or the Ryacas on Omegahat - Download links)
- Nov 16/06. Ryacas 0.2-3 is available from google groups (see Ryacas on google groups - Download link to right). Note that google groups has the annoying habit of translating dashes in filenames to spaces so after downloading the file you will have to change the name so that any spaces are replaced with dashes.
TECHNOLOGY
Ryacas is written in R. It uses a recursive decent R-to-yacas translator and an XML-based OpenMath yacas-to-R translator. Yacas is accessed via a thin C++ wrapper generated by Rcpp.
SOURCE REPOSITORY
The git repository on GitHub (click on View on GitHub button above) contains the source code of Ryacas and generated PDF file for the vignette.
STATUS
- Ryacas
- The Ryacas package was developed several years ago and development has largely stopped (although a bug fix version was issued Feb 5, 2010) and now effort goes into the rMathpiper and rSymPy projects.
- Yacas
- Regarding yacas itself (as opposed to Ryacas), the original developer behind yacas appears to have left the yacas project. Just before he left he rewrote yacas in Java. Currently Alberto González Palomo continues to make improvements to the C version yacas although there have been no recent releases.
- MathpiperIDE
- The java version of yacas was adopted by the MathpiperIDE project in 2008 (which had been called Mathrider at the time and though the name has since been changed) and Ted Kosan has indicated that under the MathpiperIDE/Mathrider project he has forked the java version of yacas and he and Howard "Sherm" Ostrowsky have made 2,700 svn commits (from March 2008 to October 2009) of which about half were for Mathpiper (and the rest for Mathrider). The new name Mathpiper is used to distinguish it from the apparently unmaintained yacas.jar prior to the fork. (The original version of the java version of yacas is available on the yacas site).
- Mathpiper
- Mathpiper is located at http://mathpiper.googlecode.com. The mathpiper.jar file is located in the mathrider/jars directory in the !MathPiperIDE (formerly Mathrider) distribution which can be found at http://mathrider.org. The javadocs can be found here. One can launch the GUI console like this: java -jar mathpiper.jar One can launch the text console like this: java -cp mathpiper.jar org.mathpiper.ui.text.consoles.Console and one can launch the help application like this: java -cp mathpiper.jar org.mathpiper.ui.gui.help.FunctionTreePanel One significant new feature in Mathpiper is the ability to emit R code using the following command (which puts Mathpiper in a mode such that all code emitted is R): PrettyPrinter("RForm") This new feature was added to Mathpiper version 0.76t .
R INTERFACE
There are 8 interfaces. All of them are built on top of yacas.character:
- yacas.character. Pass a raw yacas character string to yacas function. e.g.
yacas('x*x')
- yacas.expression. Pass an R expression to yacas function. e.g.
yacas(expression(x*x))
- yacas.function. Pass an R function name which defines a one-line R function. e.g.
f <- function(x) x*x; yacas(f)
- yacas.formula. Pass an R formula object whose right hand side will be regarded as an expression to pass to yacas.expression. e.g.
yacas(~ x*x)
- Sym object. These objects are internally yacas strings. They can be combined with arithmetic operators The print method calls yacas. e.g.
x <- Sym('x'); x*x
- Expr object. These objects are internally R expressions. They can be combined with artithmetic operators. e.g.
x <- Exprq(x); x*x
- yacmode() which places the session in a mode where one can directly type in yacas commands.
EXAMPLES
Sample session
> library(Ryacas)
> # algebra
> x <- Sym('x')
> (x+1) * (x-1)
expression((x + 1) * (x - 1))
> Simplify("%")
expression(x^2 - 1)
PrettyForm("%")
2
x - 1
> # calculus
> Integrate(x+tan(x), x)
expression(x^2/2 - log(cos(x)))
> # exact arithmetic
> yacas('12/24')
expression(1/2)
> # ASCII pretty printing
> exp(-x^2)/(cos(x)+exp(x))
expression(exp(-x^2)/(cos(x) + exp(x)))
> PrettyForm("%")
/ / 2 \ \
Exp\ -\ x / /
-------------------
Cos( x ) + Exp( x )
> # matrix - yacas matrices are row-wise
> List(List(1,2),List(x,6))
expression(list(list(1, 2), list(x, 6)))
> PrettyForm("%")
/ \
| ( 1 ) ( 2 ) |
| |
| ( x ) ( 6 ) |
\ /
> # output TeX
> k <- Sym('k')
> yacas(TeXForm((x+1)^2 + k^3), retclass = 'unquote')
$\left( x + 1\right) ^{2} + k ^{3}$
>
Solving nonlinear equation
> library(Ryacas)
> Asym <- Sym("Asym"); xmid <- Sym("xmid"); scal <- Sym("scal")
> x <- Sym("x"); y <- Sym("y")
> Solve(Asym/(1+exp((xmid-x)/scal))==y, x)
expression(list(x == xmid - log(Asym/y - 1) * scal))
Sample calculus session
> library(Ryacas)
Loading required package: XML
>
> x <- Sym("x")
> h <- Sym("h")
>
> # limit
> Limit(1/(1-x), x, Infinity)
expression(0)
>
> # differentiation
> deriv(x^3, x)
expression(3 * x^2)
>
> # integration: indefinite and definite
> Integrate(x^3, x)
expression(x^4/4)
> Integrate(x^3, x, 0, 1)
expression(1/4)
>
> # mean value
> Limit((cos(x+h)-cos(x))/h, h, 0)
expression(-sin(x))
>
> # min/max
> Solve(deriv(x^2-x, x) == 0, x)
expression(list(x == 1/2))
>
> # continuity
> Limit(sin(x+h^2) - sin(x-h^2), h, 0)
expression(0)
More
Not all the facilities of yacas are built into Ryacas but its easy to add them yourself -- typically with one line of code. For example, here we add an interface to the Ryacas EigenValues function and run an example.
MORE INFORMATION
The R commands
library(Ryacas)
package?Ryacas
will display pointers to the help commands, vignette, home page, demos and THANKS, WISHLIST and NEWS files. These files, including pdf versions of the vignette, can also be found in the Source repository by clicking on the Source tab above.
TEAM
Rob Goedman, goedman at mac dot com
Gabor Grothendieck, ggrothendieck at gmail dot com
Søren Højsgaard, sorenh at math.aau.dk
Ayal Pinkus, apinkus at xs4all dot nl
Grzegorz Mazur, teoretyk at gmail dot com
Contact Gabor if you need assistance, Rob if its Mac-related or Grzegorz if it's a yacas issue