simplify constant expressions typically containing radicals and functions with exact numeric arguments
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.
How it works.
The following example has a more complex step.
Here evalc determines that the expression is real but does not perform the full simplification.
simplify/constant is able to simplify further to obtain 0.
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.
The following example has nonelementary functions.
The following example has powers of trigonometric functions.
In cases as the following one (extracted from some integration problems):
The whole expression cannot be simplified by means of Re, Im, or abs.
It cannot be evaluated using hardware floats.
Error, unsupported type `('complex')('float')` 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.
The simplification routines for constant expressions is also used by simplify to simplify certain type of constant subexpressions found inside non-constant expressions
Download Help Document
What kind of issue would you like to report? (Optional)