Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/r-cas/ryacas

Ryacas: R Interface to the Yacas Computer Algebra System
https://github.com/r-cas/ryacas

Last synced: about 2 months ago
JSON representation

Ryacas: R Interface to the Yacas Computer Algebra System

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
message = FALSE
)
```

```{r, echo = FALSE}
library(Ryacas)
```

# Ryacas #

[![Build Status](https://travis-ci.org/r-cas/ryacas.svg?branch=master)](https://travis-ci.org/r-cas/ryacas)
[![Build status](https://ci.appveyor.com/api/projects/status/c8fsb1dvj5gmh703/branch/master?svg=true)](https://ci.appveyor.com/project/r-cas/ryacas/branch/master)
[![JOSS status](https://joss.theoj.org/papers/69b3947f8900504a25aa36f65d14500b/status.svg)](https://joss.theoj.org/papers/69b3947f8900504a25aa36f65d14500b)
[![DOI](https://zenodo.org/badge/36067045.svg)](https://zenodo.org/badge/latestdoi/36067045)

Ryacas is an [R](https://www.r-project.org/) interface to
the free [yacas](http://www.yacas.org) Computer Algebra
System. Ryacas allows one to send unprocessed yacas strings and
certain other R objects to
yacas process from R and get back the result. It also has
facilities for manipulating yacas strings and R expressions
destined for yacas processing.

It can be used for arbitrary-precision arithmetic, symbolic math, ASCII
pretty printing and translating R to TeX.

## Install from GitHub ##

To build and install from Github using R 3.3.0 (or later) and the R `devtools` package 1.11.0 (or later) run this command from within `R`:

```
devtools::install_github("r-cas/ryacas",
build_opts = c("--no-resave-data", "--no-manual"))
```

You can also install the package without vignettes if needed as follows:

```
devtools::install_github("r-cas/ryacas")
```

## Online info ##

For vignettes, overview, pointers to additional information, installation
instructions and a sample session see .

Yacas documentation can be found at http://yacas.readthedocs.org/.

## Contribute, issues, and support ##

Please use the issue tracker at
if you want to notify us of an issue or need support.
If you want to contribute, please either create an issue or make a pull request.

## Brief examples ##

Below we show a few examples.
We highly recommend reading the "[Getting started](http://r-cas.github.io/ryacas/articles/getting-started.html)" vignette (and the other vignettes) for a more thorough introduction to the package.

There are two interfaces: a high-level interface that
makes `yacas` objects work similar to `R` objects,
and a low-level interface where the user can write `yacas` code
and get results as strings or as `R` expressions. Below, we demonstrate both.

### High-level interface

A brief example with a polynomial is:
```{r}
x <- ysym("x")
p <- x^2+x-6
p
y_fn(p, "Factor")
p %>% y_fn("Factor")
p %>% as_r()
```

A small matrix example follows:

```{r}
A <- outer(0:3, 1:4, "-") + diag(2:5)
a <- 1:4
B <- ysym(A)
B
solve(B)
B[2, 3] <- "x"
B
b <- ysym(a)
b[1] <- "x"
b
B %*% b
t(B)
B[, 2:3]
```

### Low-level interface

Returning strings with `yac_str()`:

```{r}
yac_str("x+x+x+x")
yac_str("Factor(x^2+x-6)")
yac_str("D(x) x^2+x-6")
```

Returning `R` expressions with `yac_expr()`:

```{r}
yac_expr("x+x+x+x")
eval(yac_expr("x+x+x+x"), list(x = 4))
yac_expr("Factor(x^2+x-6)")
yac_expr("D(x) x^2+x-6")
```

Using functions easier (using [`magrittr`](https://cran.r-project.org/package=magrittr)'s pipe, `%>%`):

```{r}
"x^2+x-6" %>% y_fn("Factor") %>% yac_str()
"x^2+x-6" %>% y_fn("D(x)") %>% yac_expr()
```

Solving equations (removes the `x==` from `yacas` with the `y_rmvars()` function):

```{r}
sol <- yac_str("Solve(x^2+x-6 == 0, x)")
sol
sol %>% y_rmvars() %>% yac_str()
sol %>% y_rmvars() %>% yac_expr()
sol %>% y_rmvars() %>% yac_expr() %>% eval()
```

And output in TeX:

```{r}
"3/4 + Pi/8" %>% y_fn("Simplify") %>% y_fn("TeXForm") %>% yac_str()
```

And arbitrary precision (see also the "[Arbitrary-precision arithmetic
](http://r-cas.github.io/ryacas/articles/arbitrary-precision.html)" vignette):

```{r}
yac_str("N(Pi, 50)")
```

## Yacas ##

The package contains the yacas distribution. The development of the yacas source code is available at . For more information on yacas see or the documention directly at .

---

Mikkel Meyer Andersen, mikl at math dot aau dot dk
Rob Goedman, goedman at mac dot com
Gabor Grothendieck, ggrothendieck at gmail dot com
Søren Højsgaard, sorenh at math dot aau dot dk
Ayal Pinkus, apinkus at xs4all dot nl
Grzegorz Mazur, teoretyk at gmail dot com