R interface to ‘Giac’
Giac is a general purpose symbolic algebra software. It powers the graphical interface Xcas. This package allows to execute Giac commands in R. You can find the documentation of Giac here.
::install_github("rstudio/chromote")
remotes::install_github("stla/giacR") remotes
The ‘chromote’ package is used to create a Giac session. If the
find_chrome()
function of ‘chromote’ returns
NULL
, you can set the path to the Chrome executable (or
Chromium, Brave, etc) to the environment variable
CHROMOTE_CHROME
. Or you can pass it to the the
Giac$new
function. Since the Chrome executable is in my
system path, I can use Sys.which("chrome")
.
library(giacR)
<- Giac$new(Sys.which("chrome")) giac
$execute("2 + 3/7")
giac## [1] "17/7=2.42857142857"
$execute("gbasis([x^3 - 2*x*y, x^2*y - 2*y^2 + x], [x, y])")
giac## [1] "[x^2,x*y,2*y^2-x]"
$execute("integrate(ln(x))")
giac## [1] "x*ln(x)-x"
$execute("sum(1/(n^2), n, 1, +(infinity))")
giac## [1] "1/6*pi^2=1.64493406685"
$execute("crationalroot(2*x^3 - 3*x^2 + 8*x - 12)")
giac## [1] "[2*i,3/2,-2*i]"
$execute(
giac"apply(simplify, solve([x^2+y+z=1, x+y^2+z=1, x+y+z^2=1], [x, y, z]))"
)## [1] "list[[0,1,0],[1,0,0],[0,0,1],[sqrt(2)-1,sqrt(2)-1,sqrt(2)-1],[-sqrt(2)-1,-sqrt(2)-1,-sqrt(2)-1]]"
$execute("det([[1, 2, 3], [3/4, a, b], [c, 4, 5]])")
giac## [1] "(-6*a*c+10*a+4*b*c-8*b+3)/2"
$execute("has(x*y + u^2*z, u)")
giac## [1] "3"
$execute("has(x*y + u^2*z, w)")
giac## [1] "0"
$close()
giac## [1] TRUE