newSimplification function

newSimplification

newSimplification

Define a new simplification expression

newSimplification(expr, test, simplification, do_eval = FALSE, simpEnv = sysSimplifications)

Arguments

  • expr: An expression to simplify.
  • test: An expression to evaluate whether the simplification should be applied to expr.
  • simplification: An equivalent but simpler version of the expression.
  • do_eval: Whether the simplification should be evaluated or stored as-is.
  • simpEnv: The environment in which the simplification is stored.

Returns

If expr is missing, list all the functions with known simplifications.

If test is missing, list all the known simplifications for expr.

Otherwise, add the new simplification to the list of possible simplifications.

Examples

# The unary + operation can always be safely removed: newSimplification(+a, TRUE, a) # The unary - operation can be absorbed into numeric values: newSimplification(-a, is.numeric(a), -a, do_eval = TRUE) # Adding zero to anything can be skipped: newSimplification(a + b, isZERO(b), a)
  • Maintainer: John C Nash
  • License: GPL-2
  • Last published: 2023-09-05

Useful links