Product of a function

prod_(f, var, lower, upper, doit = TRUE)

Arguments

f

Function to take product of

var

Variable to take product for (either string or caracas_symbol)

lower

Lower limit

upper

Upper limit

doit

Evaluate the product immediately (or later with doit())

Examples

if (has_sympy()) {
  x <- symbol("x")
  p <- prod_(1/x, "x", 1, 10)
  p
  as_expr(p)
  prod(1/(1:10))
  n <- symbol("n")
  prod_(x, x, 1, n)
}
#> c: n!