1
$\begingroup$

Given that:

X={{0,0,0,0,0,1} -> -2*a*f + 3*b*f*Cos[y] - a*f*Cos[x]*Cos[y] + Sqrt[3]*a*f*Cos[y]*Sin[x]
                    + Sqrt[3]*b*f*Sin[y] - Sqrt[3]*a*f*Cos[x]*Sin[y] - a*f*Sin[x]*Sin[y],
   {0,0,0,1,0,1} -> -f^2*Cos[x]*Cos[y] + Sqrt[3]*f^2*Cos[y]*Sin[x] 
                    - Sqrt[3]*f^2*Cos[x]*Sin[y] - f^2*Sin[x]*Sin[y]}

when I execute:

Map[Map[TrigFactor, Collect[#, {a, b, f}]] &, X]

I get the following output:

{{0,0,0,0,0,1} -> f * (-2*a - a*Cos[x-y] + 3*b*Cos[y] + Sqrt[3]*a*Sin[x-y] 
                  + Sqrt[3]*b*Sin[y]),
 {0,0,0,1,0,1} -> -2*f^2*Sin[Pi/6-x+y]}

But I want this:

{{0,0,0,0,0,1} -> -2*a*f - 2*a*f*Sin[Pi/6+x-y] + 6*b*f*Sin[Pi/6+y],
 {0,0,0,1,0,1} -> -2*f^2*Sin[Pi/6-x+y]}

Does this behavior is related to not applying TrigFactor recursively?

How can I solve this?

Best Regards.

$\endgroup$
1
$\begingroup$

Map trigfactor only to the second level in the expression:

    Map[Map[TrigFactor, Collect[#, {a, b, f}], {2}] &, X]
{{0, 0, 0, 0, 0, 1} -> 
  2 Sqrt[3] b f Cos[Pi/6 - y] +  a f (-2 - 2 Sin[Pi/6 - x + y]),
 {0, 0, 0, 1, 0, 1} -> -2 f^2 Sin[Pi/6 - x + y]} 

( I think your desired output expression is off.. )

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.