3.3.10 Simplification
| Simplify[expr] | try various algebraic and trigonometric transformations to simplify an expression | | FullSimplify[expr] | try a much wider range of transformations |
Simplifying expressions. | Mathematica does not automatically simplify an algebraic expression like this. | |
In[1]:=
(1 - x)/(1 - x^2)
|
Out[1]=
|
|
| Simplify performs the simplification. | |
Out[2]=
|
|
| Simplify performs standard algebraic and trigonometric simplifications. | |
In[3]:=
Simplify[Sin[x]^2 + Cos[x]^2]
|
Out[3]=
|
|
| It does not, however, do more sophisticated transformations that involve, for example, special functions. | |
In[4]:=
Simplify[Gamma[1+n]/n]
|
Out[4]=
|
|
| FullSimplify does perform such transformations. | |
Out[5]=
|
|
FullSimplify[expr, ExcludedForms -> pattern]
| | try to simplify expr, without touching subexpressions that match pattern |
Controlling simplification. | Here is an expression involving trigonometric functions and square roots. | |
In[6]:=
t = (1 - Sin[x]^2) Sqrt[Expand[(1 + Sqrt[2])^20]]
|
Out[6]=
|
|
| By default, FullSimplify will try to simplify everything. | |
Out[7]=
|
|
| This makes FullSimplify avoid simplifying the square roots. | |
In[8]:=
FullSimplify[t, ExcludedForms->Sqrt[_]]
|
Out[8]=
|
|
FullSimplify[expr, TimeConstraint->t]
| | try to simplify expr, working for at most t seconds on each transformation |
FullSimplify[expr, TransformationFunctions -> { , , ... }]
| | use only the functions in trying to transform parts of expr |
FullSimplify[expr, TransformationFunctions -> {Automatic, , , ... }]
| | use built-in transformations as well as the |
Simplify[expr, ComplexityFunction->c] and FullSimplify[expr, ComplexityFunction->c]
| | simplify using c to determine what form is considered simplest |
Further control of simplification. In both Simplify and FullSimplify there is always an issue of what counts as the "simplest" form of an expression. You can use the option ComplexityFunction -> c to provide a function to determine this. The function will be applied to each candidate form of the expression, and the one that gives the smallest numerical value will be considered simplest. | With its default definition of simplicity, Simplify leaves this unchanged. | |
In[9]:=
Simplify[4 Log[10]]
|
Out[9]=
|
|
| This now tries to minimize the number of elements in the expression. | |
In[10]:=
Simplify[4 Log[10], ComplexityFunction -> LeafCount]
|
Out[10]=
|
|
|