simplify/size
simplify the size of mathematical expressions by appropriately collecting subexpressions
Calling Sequence
Parameters
Description
Examples
simplify(expr, size, evaluate_known_functions = eval_boolean)
simplify(expr, size = false)
simplify(expr, size = false, ...)
expr
-
expression
size
literal name; size
evaluate_known_functions = eval_boolean
(optional) equation; left-hand side is the literal evaluate_known_functions and the right-hand side eval_boolean is true or false. This equation controls whether functions are re-evaluated after simplification
...
arguments for any other calling sequence for simplify
The simplify(expr, size) calling sequence is used to attempt simplifying the expression size, performing only collections and simple decomposition of fractional powers in the coefficients - sometimes taking advantage of linear factors when they exist. No other mathematical simplifications of the expression or its subexpressions is performed. These operations, while simple and with low computational cost, may remarkably structure the expression and reduce its size.
The concept of size used by these routines is close to the concept of length, but function calls and radicals are considered of bigger size than mathematically simpler objects of the same length. In this framework size partly includes the idea of mathematical complexity (for advanced users, see the routines `simplify/size/size` and `simplify/size/size/object`).
The approach used consists of collecting subexpressions using an ordering based on size, then searching for possible fractional decompositions or linear factors that lead to coefficients of smaller size. Functions are handled by first simplifying in size their arguments, followed by re-evaluating the function when the simplification leads to simpler arguments. To avoid re-evaluating the functions, use the optional argument evaluate_known_functions=false.
Expressions given as a ratio between two subexpressions have the numerator and denominator simplified in size separately, and the returned result constructed by dividing the expressions obtained (whenever this result is simpler than the given expression).
The simplification of the expression size is performed automatically by the simplify command, as part of its default operation, for all calling sequences. To perform only simplification of the expression size, and no other simplifications, invoke the routines by calling simplify with the extra argument size. Alternatively, the simplification of size is an option in the context menu (Simplify > Size).
To disable simplification of the expression size, you can pass the option size = false to the simplify command. The option size = false can be included with any simplify calling sequence. Other simplifications cannot be turned off in the same way: this feature is exclusive to simplification with respect to size.
e1≔14⁢exp⁡−14⁢x2⁢214⁢x32+18⁢exp⁡14⁢x2⁢234⁢sqrt⁡x⁢sqrt⁡π⁢erf⁡12⁢sqrt⁡2⁢x+18⁢exp⁡14⁢x2⁢234⁢x52⁢sqrt⁡π⁢erf⁡12⁢sqrt⁡2⁢x:
A call to simplify simplifies the expression considerably.
simplify⁡e1
214⁢2⁢π⁢erf⁡2⁢x2⁢x2+1⁢ⅇx24+2⁢x⁢ⅇ−x24⁢x8
This simplification comes entirely from the manipulations by the simplify/size routines.
simplify⁡e1,size
In the following example, the full set of applicable simplifications (including simplifying with respect to size) leads to the same result as just simplification with respect to size.
e2≔−3⁢sin⁡x12⁢cos⁡x2⁢sin⁡xm+3⁢sin⁡x12⁢cos⁡x2⁢cos⁡xn+4⁢sin⁡x12⁢cos⁡x4⁢sin⁡xm−4⁢sin⁡x12⁢cos⁡x4⁢cos⁡xn
e2≔−3⁢sin⁡x⁢cos⁡x2⁢sin⁡xm+3⁢sin⁡x⁢cos⁡x2⁢cos⁡xn+4⁢sin⁡x⁢cos⁡x4⁢sin⁡xm−4⁢sin⁡x⁢cos⁡x4⁢cos⁡xn
simplify⁡e2
−4⁢cos⁡x2−34⁢cos⁡xn−sin⁡xm⁢cos⁡x2⁢sin⁡x
simplify⁡e2,size
Disabling the simplification with respect to size leads to a slightly different result.
simplify⁡e2,size=false
−4⁢cos⁡x2+3⁢cos⁡xn−sin⁡xm⁢sin⁡x⁢cos⁡x2
Exclusively performing simplification with respect to size will miss some types of simplification that would be found otherwise.
e3≔sin⁡x2+cos⁡x2
simplify⁡e3
1
simplify⁡e3,size
sin⁡x2+cos⁡x2
In this case, we could skip simplifying with respect to size. For large expressions, this may be a bit more efficient.
simplify⁡e3,size=false
An example using the optional argument evaluate_known_functions.
one≔exp⁡x⁢a−a−x−1⁢a
one≔ⅇx⁢a−a−x−1⁢a
one=simplify⁡one,size
ⅇx⁢a−a−x−1⁢a=1
one=simplify⁡one,size,evaluate_known_functions=false
ⅇx⁢a−a−x−1⁢a=ⅇ0
See Also
collect
convert/horner
factors
simplify
Download Help Document