simplify/constant
simplify constant expressions typically containing radicals and functions with exact numeric arguments
Calling Sequence
Parameters
Description
Examples
simplify(expr, constant)
expr
-
expression
constant
literal name; constant
The simplify(expr, constant) calling sequence is used to simplify expressions that are of type,constant and typically contain radicals or mathematical functions having exact numeric arguments.
The approach used consists of applying a set of simplification procedures (SP) in two steps:
1) The constant objects, in the form of sums, products, or function calls, are simplified using SP, starting with the inner most one and composing simplifications at each step. The routines can handle with reasonable efficiency products of fractional powers, exponentials, and various functions calls together with their multiplicative inverses.
2) When the resulting expression still contains radicals, the simplification procedure applied to each object in the previous step is applied once more, this time to the whole expression.
The simplification procedures SP used in the itemization above consist of analyzing the Real and Imaginary parts of the expression in order to conclude about possible cancellations or simpler representations. In addition, if the expression or subexpression can be evaluated numerically fast, using hardware floats, this information is used as a starting point to determine an exact rational value for the object, if that value exists.
The simplify/constant routines do take assumptions into account up to the point Re, Im, and abs take them.
The simplification of constant subexpressions entering input for simplify is performed automatically. However, to invoke this set of simplification routines, call simplify with the extra argument constant.
e1≔1+2⁢cos⁡27⁢π−2⁢cos⁡37⁢π−2⁢cos⁡17⁢π
e1≔1+2⁢cos⁡2⁢π7−2⁢cos⁡3⁢π7−2⁢cos⁡π7
simplify⁡e1,constant
0
How it works.
abs⁡e1
The following example has a more complex step.
e2≔−167−−117+−147+−127−−137+1−−157
Here evalc determines that the expression is real but does not perform the full simplification.
evalc⁡e2
1+2⁢cos⁡2⁢π7−2⁢cos⁡3⁢π7−2⁢cos⁡π7
simplify/constant is able to simplify further to obtain 0.
simplify⁡e2,constant
This example shows that these simple manipulations of the real and imaginary parts are not enough, but the expression is (in this case by construction) equal to a rational number.
e3≔e2−1753
e3≔−167−−117+−147+−127−−137+3653−−157
simplify⁡e3,constant
−1753
The following example has nonelementary functions.
e4≔164⁢Ψ⁡1,18⁢π⁢csc⁡18⁢πΓ⁡78+164⁢Ψ⁡182⁢π⁢csc⁡18⁢πΓ⁡78−164⁢π⁢Ψ⁡1,18sin⁡18⁢π⁢Γ⁡78−164⁢π⁢Ψ⁡182sin⁡18⁢π⁢Γ⁡78+1
e4≔Ψ⁡1,18⁢π⁢csc⁡π864⁢Γ⁡78+Ψ⁡182⁢π⁢csc⁡π864⁢Γ⁡78−π⁢Ψ⁡1,1864⁢sin⁡π8⁢Γ⁡78−π⁢Ψ⁡18264⁢sin⁡π8⁢Γ⁡78+1
simplify⁡e4,constant
1
The following example has powers of trigonometric functions.
e5≔−12007⁢cos⁡37⁢π2⁢cos⁡17⁢π+1287⁢cos⁡37⁢π6−47⁢cos⁡37⁢π⁢120⁢cos⁡37⁢π⁢cos⁡17⁢π−192⁢cos⁡37⁢π5−12007⁢cos⁡27⁢π2⁢cos⁡37⁢π+1287⁢cos⁡27⁢π6+47⁢cos⁡27⁢π⁢−120⁢cos⁡37⁢π⁢cos⁡27⁢π+192⁢cos⁡27⁢π5+12007⁢cos⁡27⁢π⁢cos⁡17⁢π2+1287⁢cos⁡17⁢π6−47⁢cos⁡17⁢π⁢−120⁢cos⁡17⁢π⁢cos⁡27⁢π−192⁢cos⁡17⁢π5
e5≔−1200⁢cos⁡3⁢π72⁢cos⁡π77+128⁢cos⁡3⁢π767−4⁢cos⁡3⁢π7⁢120⁢cos⁡3⁢π7⁢cos⁡π7−192⁢cos⁡3⁢π757−1200⁢cos⁡2⁢π72⁢cos⁡3⁢π77+128⁢cos⁡2⁢π767+4⁢cos⁡2⁢π7⁢−120⁢cos⁡3⁢π7⁢cos⁡2⁢π7+192⁢cos⁡2⁢π757+1200⁢cos⁡2⁢π7⁢cos⁡π727+128⁢cos⁡π767−4⁢cos⁡π7⁢−120⁢cos⁡π7⁢cos⁡2⁢π7−192⁢cos⁡π757
simplify⁡e5,constant
166
In cases as the following one (extracted from some integration problems):
e6≔−12⁢I⁢exp⁡I⁢Ei⁡1,I−12⁢Ei⁡1,I⁢sin⁡1+12⁢I⁢Ei⁡1,I⁢cos⁡1−12⁢Ei⁡1,−I⁢sin⁡1−12⁢I⁢Ei⁡1,−I⁢cos⁡1+12⁢I⁢exp⁡−I⁢Ei⁡1,−I
e6≔−I⁢ⅇI⁢Ei1⁡I2−Ei1⁡I⁢sin⁡12+I⁢Ei1⁡I⁢cos⁡12−Ei1⁡−I⁢sin⁡12−I⁢Ei1⁡−I⁢cos⁡12+I⁢ⅇ−I⁢Ei1⁡−I2
The whole expression cannot be simplified by means of Re, Im
ℜ⁡e6
−ℜ⁡Ei1⁡I⁢sin⁡1+Ei1⁡−I⁢sin⁡12+ℑ⁡ⅇI⁢Ei1⁡I−Ei1⁡I⁢cos⁡1+Ei1⁡−I⁢cos⁡1−ⅇ−I⁢Ei1⁡−I2
It cannot be evaluated using hardware floats.
evalhf⁡e6
Error, unsupported type `indexed` in evalhf
Some subexpressions of it can be simplified by properly manipulating these procedures and that suffices to collapse the original problem into something within the scope of these simpler manipulations, here leading to the following.
simplify⁡e6,constant
The simplification routines for constant expressions is also used by simplify to simplify certain type of constant subexpressions found inside non-constant expressions
e7≔12⁢212⁢−4⁢1+21212+2⁢2⁢212−212⁢π+2⁢212−212⁢π⁢212+2⁢π12⁢2⁢212−212+π12⁢212⁢2⁢212−212+2⁢x⁢2⁢212−212+x⁢212⁢2⁢212−2122⁢212−212⁢212−1⁢1+2122
e7≔2⁢−4⁢1+2+2⁢2⁢2−2⁢π+2⁢2−2⁢π⁢2+2⁢π⁢2⁢2−2+π⁢2⁢2⁢2−2+2⁢x⁢2⁢2−2+x⁢2⁢2⁢2−22⁢2⁢2−2⁢2−1⁢1+22
type⁡e7,constant
false
simplify⁡e7
−2+π+π+x
See Also
abs
evalhf
Im
Re
simplify
Download Help Document