MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: A Problem with Simplify

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87497] Re: A Problem with Simplify
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 11 Apr 2008 05:57:47 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ftkb7f$a9m$1@smc.vnet.net> <ftmts8$4l5$1@smc.vnet.net>

Alexey Popkov wrote:

<snip>

> 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.

<snip>

This is not a bug, indeed. As a rule of thumb, *FullSimplify* tries to 
minimize the leaf count of the expression.

For the case above, the original expression sin(x)cos(x) has a leaf 
count of 5 whereas the trigonometric identity sin(2x)/2 has a leaf count 
of 8. Therefore, *FullSimplify* returns the original form sin(x)cos(x) 
since it is deemed as simpler than sin(2x)/2 w.r.t. the lead count of 
each expression.

Note that, in general, you can modify/tweak this default behavior to 
suit your needs by witting your own *ComplexityFunction*. However, when 
dealing with trigonometric expressions (especially when looking for some 
trigonometric identities) it is usually better and less cumbersome to 
use  *TrigReduce* and the like (*TrigExpand*, *TrigFactor*, etc.).


     FullSimplify[Sin[x]*Cos[x]]      (* returns  Cos[x] Sin[x]  *)
     % // LeafCount                   (* returns  5              *)
     TrigReduce[Sin[x]*Cos[x]]        (* returns  1/2 Sin[2 x]   *)
     % // LeafCount                   (* returns  8              *)
     LeafCount[Cosh[x] - Sinh[x]]     (* returns  7              *)
     FullSimplify[Cosh[x] - Sinh[x]]  (* returns  E^-x           *)
     % // LeafCount                   (* returns  5              *)


Best regards,
-- Jean-Marc


  • Prev by Date: Ranks for an array of triplets
  • Next by Date: Re: JLink Problem, Fixed More or Less
  • Previous by thread: Re: A Problem with Simplify
  • Next by thread: Re: A Problem with Simplify