FullSimplify results
- To: mathgroup at smc.vnet.net
- Subject: [mg12800] FullSimplify results
- From: Ersek_Ted%PAX1A at mr.nawcad.navy.mil
- Date: Fri, 12 Jun 1998 04:05:32 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Consider the following:
In[1]:=
FullSimplify[ -E^(-x) ]//InputForm
Out[1]//InputForm=
-Cosh[x] + Sinh[x]
In[2]:=
{ LeafCount[-Cosh[x]+Sinh[x]], LeafCount[ -E^(-x) ] }
Out[2]=
{7, 7}
Note:
The output of FullSimplify has the same LeafCount as the expression it
started with.
How does FullSimplify decide that it likes (-Cosh[x]+Sinh[x]) better?
The online help for ComplexityFunction indicates: "With the default
setting ComplexityFunction->Automatic, forms are ranked primarily
according to their LeafCount, with corrections to treat integers with
more digits as more complex".
There has to be more to it than that because that doesn't explain the
result above.
I came up with a ComplexityFunction (see in In[3] below) that will often
give the same result as the default ComplexityFunction, but it
sometimes gives a result that I like a little better. My
ComplexityFunction adds a little bit of complexity for each symbol in
the expression. NonNumeric symbols are considered a bit more complex
than Numeric symbols.
In[3]:=
SetOptions[FullSimplify,
ComplexityFunction->(LeafCount[#]+
0.0001*Count[#,var_Symbol/;Not[NumericQ[var]],Infinity]+
0.00006*Count[#,var_Symbol/;NumericQ[var],Infinity]&)];
In[4]:=
FullSimplify[-Cosh[x]+Sinh[x]]//InputForm
Out[4]//InputForm=
-E^(-x)
In[5]:=
FullSimplify[-E^(-x)]//InputForm
Out[5]//InputForm=
-E^(-x)
In the lines above we see FullSimplify now prefers (-E^(-x)) over
(-Cosh[x]+Sinh[x] ).
The online help ComplexityFunction has corrections to treat integers
with more digits as more complex. I haven't come up with a case where
that would be relevant. If anyone can come up with an example please
let me know.
Can anyone demonstrate that the default ComplexityFunction is (in some
sense) better than the one I give above? Does anyone want to propose
their own ComplexityFunction?
Ted Ersek
- Follow-Ups:
- Re: FullSimplify results
- From: Daniel Lichtblau <danl>
- Re: FullSimplify results