Re: Question about trig simplify
- To: mathgroup at smc.vnet.net
- Subject: [mg71168] Re: [mg71099] Question about trig simplify
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Thu, 9 Nov 2006 03:40:21 -0500 (EST)
- References: <200611081115.GAA22432@smc.vnet.net>
Compare the LeafCounts:
In[1]:=In[1]:=
LeafCount[2*Sin[a]*Cos[a]]
Out[1]=
6
In[2]:=
LeafCount[Sin[2a]]
Out[2]=
4
So the simplified expression is "simpler" according to the defaul
ComplexityFunction (which is more or less LeafCount). On the other hand:
In[4]:=
LeafCount[-Sin[2 a]]
Out[4]=
6
In[5]:=
LeafCount[-2Cos[a] Sin[a]]
Out[5]=
6
So there is no ground for replacing one expression by the other. You
need to use a different ComplexityFunction. I like to use this:
VisibleSimplify[expr_, opts___] := Simplify[
expr, opts, ComplexityFunction -> \
(StringLength[ToString[TraditionalForm[#]]] &)]
Then:
In[11]:=
VisibleSimplify[2*Sin[a]*Cos[a]]
Out[11]=
Sin[2*a]
In[12]:=
VisibleSimplify[-2*Cos[a]*Sin[a]]
Out[12]=
-Sin[2*a]
Andrzej Kozlowski
Tokyo, Japan
On 8 Nov 2006, at 20:15, Robert Pigeon wrote:
>
> Hello all,
> Is this a bug?
>
> 2*Sin[a]*Cos[a] // Simplify gives Sin[2 a] as expected.
>
> But
>
> -2*Sin[a]*Cos[a] // Simplify gives -2*Cos[a]*Sin[a] ...... Why?
> If I do -2*(Sin[a]*Cos[a]) // Simplify I get the same answer.
>
> This comes from the rotation matrix: r = {{Cos[a],Sin[a]},{-Sin
> [a],Cos[a]}}.
> Then I do: r.r // Simplify. That gives: {{Cos[2 a],Sin[2 a]},{-2 Cos
> [a]
> Sin[a],Cos[2 a]}}. It does not matter if I do a FullSimplify
> instead of
> Simplify.
>
> After if I do r.r.r // Simplify. The answer is simplified correctly.
>
> I am using Mathematica 5.2 on Windows XP Home.
>
> Any idea?
>
> Robert
>
> Robert Pigeon
> TZ = -5
>
- References:
- Question about trig simplify
- From: Robert Pigeon <robert.pigeon@videotron.ca>
- Question about trig simplify