-
Notifications
You must be signed in to change notification settings - Fork 8
/
README.Rmd
executable file
·171 lines (124 loc) · 4.53 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit only README.Rmd! -->
```{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 <http://r-cas.github.io/ryacas/>.
Yacas documentation can be found at http://yacas.readthedocs.org/.
## Contribute, issues, and support ##
Please use the issue tracker at <https://github.com/r-cas/ryacas/issues>
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 <https://github.com/grzegorzmazur/yacas/> . For more information on yacas see <http://www.yacas.org/> or the documention directly at <https://yacas.readthedocs.io/>.
---
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