MathGroup Archive 2008

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

Search the Archive

Re: A Problem with Simplify

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87515] Re: A Problem with Simplify
  • From: Alexey Popkov <popkov at gmail.com>
  • Date: Sat, 12 Apr 2008 06:56:50 -0400 (EDT)
  • References: <ftkb7f$a9m$1@smc.vnet.net> <ftmts8$4l5$1@smc.vnet.net>

On 11 =C1=D0=D2, 13:59, Jean-Marc Gulliet <jeanmarc.gull... at gmail.com>
wrote:
> 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

Big thanks! I did not understand this from the documentation. But now
this become clear.


  • Prev by Date: Re: Problem for using "Epilog" to plot legend
  • Next by Date: Re: Documentation - what is the big secret?
  • Previous by thread: Re: A Problem with Simplify
  • Next by thread: Re: A Problem with Simplify