sympy_func: Call a SymPy function directly on x

View source: R/sym_symbol.R

sympy_funcR Documentation

Call a SymPy function directly on x

Description

Extend caracas by calling SymPy functions directly.

Usage

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)
}
 

caracas documentation built on June 22, 2024, 10:59 a.m.