Symbolic differentiation of an expression

der(expr, vars, simplify = TRUE)

Arguments

expr

A caracas_symbol

vars

variables to take derivate with respect to

simplify

Simplify result

Examples

if (has_sympy()) {
  x <- symbol("x")
  y <- symbol("y")
  f <- 3*x^2 + x*y^2
  der(f, x)
  g <- der(f, list(x, y))
  g
  dim(g)
  G <- matrify(g)
  G
  dim(G)
  
  h <- der(g, list(x, y))
  h
  dim(h)
  as.character(h)
  H <- matrify(h)
  H
  dim(H)
  
  g %>% 
    der(list(x, y), simplify = FALSE) %>% 
    der(list(x, y), simplify = FALSE) %>% 
    der(list(x, y), simplify = FALSE)
}
#> c: ⎡⎡0  0⎤  ⎡0  0⎤⎤
#>    ⎢⎢    ⎥  ⎢    ⎥⎥
#>    ⎢⎣0  0⎦  ⎣0  0⎦⎥
#>    ⎢              ⎥
#>    ⎢⎡0  0⎤  ⎡0  0⎤⎥
#>    ⎢⎢    ⎥  ⎢    ⎥⎥
#>    ⎣⎣0  0⎦  ⎣0  0⎦⎦