Re: Re: A Problem with Simplify
- To: mathgroup at smc.vnet.net
- Subject: [mg87503] Re: [mg87456] Re: A Problem with Simplify
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Fri, 11 Apr 2008 05:58:55 -0400 (EDT)
- References: <ftkb7f$a9m$1@smc.vnet.net> <200804110542.BAA04641@smc.vnet.net>
On 11 Apr 2008, at 14:42, Alexey Popkov wrote:
> Recently I also have found another strange bug in Simplfy (not so
> dangerous):
> FullSimplify[Sin[x]*Cos[x]]
> gives Sin[x]*Cos[x] instead Sin[2*x]/2. The workaround is
> FullSimplify[2*Sin[x]*Cos[x]]/2
This is not a bug!
In[7]:= LeafCount[Sin[x]*Cos[x]]
Out[7]= 5
In[8]:= LeafCount[Sin[2*x]/2]
Out[8]= 8
In other words, Sin[x] Cos[x] is considered simpler by Simplify than
Sin[2*x]/2, that's all. Indeed:
In[9]:= Simplify[Sin[2*x]/2]
Out[9]= Cos[x]*Sin[x]
If you want Simplify to return Sin[2*x]/2 use a different complexity
functions:
Simplify[Sin[x]*Cos[x], ComplexityFunction ->
(LeafCount[#1] + 10*Count[#1, _Cos,
Infinity] & )]
(1/2)*Sin[2*x]
And, by the way, your "other bug" is also not a bug.
A basic principle worth remembering: just because something seems
wrong to you does not mean it is wrong.
Andrzej Kozlowski
- References:
- Re: A Problem with Simplify
- From: Alexey Popkov <popkov@gmail.com>
- Re: A Problem with Simplify