newSimplification: newSimplification

View source: R/derivs.R

newSimplificationR Documentation

newSimplification

Description

Define a new simplification expression

Usage

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.

Value

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)

nlsr documentation built on Sept. 8, 2023, 5:48 p.m.