MyNixOS website logo
Description

Computer Algebra.

Computer algebra via the 'SymPy' library (<https://www.sympy.org/>). This makes it possible to solve equations symbolically, find symbolic integrals, symbolic sums and other important quantities.

caracas: Computer algebra in R

R buildstatus codecov

Installation

caracas is available on CRAN and can be installed as usual:

install.packages('caracas')

Please ensure that you have SymPy installed, or else install it:

if (!caracas::has_sympy()) {
  caracas::install_sympy() 
}

To build and install from Github with vignettes run this command from within R (please install remotes first if not already installed):

# install.packages('remotes')
remotes::install_github("r-cas/caracas", build_vignettes = TRUE)

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

remotes::install_github("r-cas/caracas")

Configuring the Python environment

The caracas package uses the reticulate package (to run Python code). Thus, if you wish to configure your Python environment, you need to 1) load reticulate, 2) configure the Python environment, and 3) load caracas. The Python environment can be configured as described here. Again, this need to be done before loading caracas.

Development site

See https://github.com/r-cas/caracas.

Online documentation

See https://r-cas.github.io/caracas/.

Origin of name

The name “caracas” is intended to mean “(inter)face to computer algebra system(s)” - notice that “cara” is Spanish (Castellano to be precise) for “face”.

Code of conduct

Please note that the caracas project is released with a Contributor Code of Conduct (available in CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.

Brief introduction

library(caracas)
# options(caracas.print.prettyascii = TRUE)
x <- symbol('x')
eq <- 2*x^2 - x
eq
#> c:    2    
#>    2⋅x  - x
as.character(eq)
#> [1] "2*x^2 - x"
as_expr(eq)
#> expression(2 * x^2 - x)
tex(eq)
#> [1] "2 x^{2} - x"
solve_sys(eq, x)
#> x = 0
#> x = 1/2
der(eq, x)
#> c: 4⋅x - 1
subs(eq, x, "y")
#> c:    2    
#>    2⋅y  - y
A <- matrix(c("x", 2, 0, "2*x"), 2, 2)
B <- as_sym(A)
B
#> c: ⎡x   0 ⎤
#>    ⎢      ⎥
#>    ⎣2  2⋅x⎦
Binv <- inv(B)
Binv
#> c: ⎡ 1      ⎤
#>    ⎢ ─    0 ⎥
#>    ⎢ x      ⎥
#>    ⎢        ⎥
#>    ⎢-1    1 ⎥
#>    ⎢───  ───⎥
#>    ⎢  2  2⋅x⎥
#>    ⎣ x      ⎦
tex(Binv)
#> [1] "\\left[\\begin{matrix}\\frac{1}{x} & 0\\\\- \\frac{1}{x^{2}} & \\frac{1}{2 x}\\end{matrix}\\right]"
eigenval(Binv)
#> [[1]]
#> [[1]]$eigval
#> c: 1
#>    ─
#>    x
#> 
#> [[1]]$eigmult
#> [1] 1
#> 
#> 
#> [[2]]
#> [[2]]$eigval
#> c:  1 
#>    ───
#>    2⋅x
#> 
#> [[2]]$eigmult
#> [1] 1

Please find more examples in the other vignettes available at https://r-cas.github.io/caracas/.

Contribute, issues, and support

Please use the issue tracker at https://github.com/r-cas/caracas/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.

Metadata

Version

2.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows