Find common subexpressions
This function finds common subexpressions in an expression vector so that duplicate computation can be avoided.
An expression vector or language object.
Whether to call
The prefix to use for locally created variables.
Additional parameters to pass to
This function identifies all repeated subexpressions in an expression vector,
and stores them in locally created variables. It is used by
to share common subexpressions between expression evaluations and gradient
evaluations, for example.
TRUE, the assumptions behind the simplifications done
Simplify must be valid for the result to match the input. With
the default simplifications, this means that all variables should take finite
A language object which evaluates to an expression vector which would evaluate to the same result as the original vector with less duplicated code but more storage of intermediate results.
findSubexprs(expression(x^2, x-y, y^2-x^2))
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.