Extend caracas by calling SymPy functions directly.

sympy_func(x, fun, ...)

Arguments

x

Object to call fun on

fun

Function to call

...

Passed on to fun

Examples

if (has_sympy()) {
  def_sym(x, a)
  p <- (x-a)^4
  p
  q <- p %>% sympy_func("expand")
  q
  q %>% sympy_func("factor")
  
  def_sym(x, y, z)
  expr <- x*y + x - 3 + 2*x^2 - z*x^2 + x^3
  expr
  expr %>% sympy_func("collect", x) 
  
  x <- symbol("x")
  y <- gamma(x+3)
  sympy_func(y, "expand_func")
  expand_func(y)
}
#> c: x⋅(x + 1)⋅(x + 2)⋅Γ(x)