TransformationFunctions¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
TransformationFunctions
is an option for Simplify giving the list of functions to apply to try to transform parts of an expression.
Notes
TransformationFunctions -\> Automatic uses the built-in collection of transformation functions. TransformationFunctions -\> {f1, f2, ...} uses only the functions fi. TransformationFunctions -\> {Automatic, f1, ...} uses the built-in transformation functions together with the fi. Each function is applied to the whole expression and to its subexpressions; the lowest-complexity result (per ComplexityFunction) is kept.Examples (6)¶
Every input below was run against the current Mathilda build and its output recorded.
Options (2)¶
In[1]:= Simplify[(x^2 - 1)/(x - 1), TransformationFunctions -> {Cancel}]
Out[1]= 1 + x
In[2]:= Simplify[Sin[x]^2 + Cos[x]^2, TransformationFunctions -> {}]
Out[2]= Cos[x]^2 + Sin[x]^2
Applications (4)¶
In[3]:= Simplify[Cos[x]^2 + Sin[x]^2, TransformationFunctions -> {Automatic}]
Out[3]= 1
In[4]:= Simplify[Cos[x]^2 + Sin[x]^2, TransformationFunctions -> {}]
Out[4]= Cos[x]^2 + Sin[x]^2
In[5]:= Simplify[Cos[x]^2 + Sin[x]^2, TransformationFunctions -> {f}]
Out[5]= 1
In[6]:= Simplify[1 + Tan[x]^2, TransformationFunctions -> {Automatic, TrigToExp}]
Out[6]= Sec[x]^2
Implementation notes¶
Algorithm. TransformationFunctions is an option symbol for Simplify (it has
no builtin handler of its own). builtin_simplify detects
Rule[TransformationFunctions, spec] among its arguments and resolves it into a
(use_builtin, user_funcs[]) pair: Automatic (the default) keeps the built-in
transform pipeline only; {f1, ...} suppresses the built-ins and uses only the
fi; {Automatic, f1, ...} runs the built-in pipeline and the fi; a bare
f is treated as the single-function list {f}. The fi are borrowed pointers
into the option expression (the evaluator keeps it alive across the call). After
the built-in search produces best (or, when built-ins are suppressed, best =
expr_copy(input)), simp_apply_transformations applies each user function to
the current best and keeps the lowest-complexity result by score_with_func.
Data structures. No state beyond the parsed option; user_funcs is a small
heap array of borrowed Expr* head expressions, freed after the search.
- Each
fimay be any function — a builtin head such asTogetherorCancel, or a pure function such as(# /. a -> 0 &). - Every function is applied to the whole expression and to each of its
subexpressions; the candidate of lowest complexity (per
ComplexityFunction) is kept, in the same minimum-complexity search used for the built-in transforms. - The option propagates through
Simplify's list / relation threading and through the inexact-input rationalise/numericalise path.
Attributes: none registered.
References¶
See also: Simplify, Together, Cancel
- Source:
src/simp/simp_builtins.c - Specification:
docs/spec/builtins/simplification.md