[Date Index] [Thread Index] [Author Index]
Re: A Problem with Simplify
On 11 =C1=D0=D2, 14:00, Andrzej Kozlowski <a... at mimuw.edu.pl> wrote: > 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:= LeafCount[Sin[x]*Cos[x]] > Out= 5 > > In:= LeafCount[Sin[2*x]/2] > Out= 8 > > In other words, Sin[x] Cos[x] is considered simpler by Simplify than =9A > Sin[2*x]/2, that's all. Indeed: > > In:= Simplify[Sin[2*x]/2] > Out= Cos[x]*Sin[x] > > If you want Simplify to return Sin[2*x]/2 use a different complexity =9A > functions: > > =9A Simplify[Sin[x]*Cos[x], ComplexityFunction -> > =9A =9A =9A (LeafCount[#1] + 10*Count[#1, _Cos, > =9A =9A =9A =9A =9A =9A =9A =9AInfinity] & )] > =9A (1/2)*Sin[2*x] This is very useful example for me. Thank you. Now it is clear.