Message Boards Message Boards

0
|
5859 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Convert sum of Sin[] or Cos[] to product?

Posted 8 years ago

Hi,

I am trying to convert a sum/difference of Cos[] into a product with the well know set of identities:

r0 = {Cos[U_] -> Cos[Expand[U]], Sin[U_] -> Sin[Expand[U]],
        Cos[U_] + Cos[V_] -> 2*Cos[(U + V)/2]*Cos[(U - V)/2],
        Cos[U_] - Cos[V_] -> -2*Sin[(U + V)/2]*Sin[(U - V)/2],
        Sin[U_] + Sin[V_] -> 2*Sin[(U + V)/2]*Cos[(U - V)/2],
        Sin[U_] - Sin[V_] -> -2*Sin[(U - V)/2]*Cos[(U + V)/2],
         k_*(B + C) -> k*Pi - k*A, B + C -> Pi - A}
(* The expression to be converted is : *)
zz = 13 Cos[A] - 8 Cos[3 A] + Cos[5 A] - Cos[B - 5 C] + 5 Cos[B - 3 C] -  9 Cos[B - C] - 4 Cos[4 A] Cos[B - C] 
- Cos[3 (B - C)] + 5 Cos[3 B - C] - Cos[5 B - C] + 8 Cos[3 B + C] - 2 Cos[5 B + C] +  8 Cos[B + 3 C] - 2 Cos[B + 5 C]

(* For a better conversion, some terms should be paired previously, for examples:
    8 Cos[3 B + C] +  8 Cos[B + 3 C]       ( Note the form k_*Cos[p_*B + q_*C] + k_*Cos[q_*B + p_*C] )
  and
    - Cos[B - 5 C] - Cos[5 B - C]          ( Note the form k_*Cos[p_*B - q_*C] + k_*Cos[q_*B - p_*C] )
  so, I created the following set of rules: *)
r1 = {Cos[U_] -> Cos[Expand[U]], Sin[U_] -> Sin[Expand[U]], 
  k_*Cos[p_*B + q_*C] + k_*Cos[q_*B + p_*C] ->  2*k*Cos[(p + q)/2*(B + C)]*Cos[(p - q)/2*(B - C)], 
  k_*Cos[p_*B + q_*C] - k_*Cos[q_*B + p_*C] -> -2*k*Sin[(p + q)/2*(B + C)]*Sin[(p - q)/2*(B - C)], 
  k_*Sin[p_*B + q_*C] + k_*Sin[q_*B + p_*C] ->  2*k*Sin[(p + q)/2*(B + C)]*Cos[(p - q)/2*(B - C)], 
  k_*Sin[p_*B + q_*C] - k_*Sin[q_*B + p_*C] -> -2*k*Sin[(p + q)/2*(B + C)]*Cos[(p - q)/2*(B - C)],
  k_*(B + C) -> k*Pi - k*A, B + C -> Pi - A}

r2 = {Cos[U_] -> Cos[Expand[U]], Sin[U_] -> Sin[Expand[U]], 
  k_*Cos[p_*B - q_*C] + k_*Cos[q_*B - p_*C] ->  2*k*Cos[(p + q)/2*(B - C)]*Cos[(p - q)/2*(B + C)], 
  k_*Cos[p_*B - q_*C] - k_*Cos[q_*B - p_*C] -> -2*k*Sin[(p + q)/2*(B - C)]*Sin[(p - q)/2*(B + C)], 
  k_*Sin[p_*B - q_*C] + k_*Sin[q_*B - p_*C] ->  2*k*Sin[(p + q)/2*(B - C)]*Cos[(p - q)/2*(B + C)], 
  k_*Sin[p_*B - q_*C] - k_*Sin[q_*B - p_*C] -> -2*k*Sin[(p + q)/2*(B - C)]*Cos[(p - q)/2*(B + C)],
  k_*B + k_*C -> k*Pi - k*A, k_*(B + C) -> k*Pi - k*A, B + C -> Pi - A}

The problem is that none of the following commands does the desirable work;

z1=zz //. r1;
z1=Simplify[zz //. r1,Trig];
z2=z1 //. r2;
z2=Simplify[z1 //. r2,Trig];

I also has changed Trig to False without success.

Does any one have a suggestion in order to make these conversions ?

Thanks in advance

César Lozada

POSTED BY: Cesar Lozada

Seems that r0 need some minor (and rather important) corrections

  1. Cos[U_]-> Cos[Expand[U]] - Expand will not be used as this is an immediate rule and need to be replaced with a delayed rule :>, etc (see below)
  2. Cos[U_]+Cos[V_]-> 2*Cos[... etc. you do not cover the case of each of the cosines be multiplied with the same numbers. so you need to change this to a. Cos[U] + a. Cos[V] :> ... which means that if there is no a it is equal to 1 and the pattern is matched. Although the delayed rule here is not crucial, I prefer to use it almost always. Only the cases where the right hand side of the rule needs heavy computation that can be performed once I use a rule of the form -> Now

    r0 = {Cos[U_] :> Cos[Expand[U]], Sin[U_] :> Sin[Expand[U]], 
      a_. Cos[U_] + a_. Cos[V_] :> 2*a Cos[(U + V)/2]*Cos[(U - V)/2], 
      a_. Cos[U_] - a_. Cos[V_] :> -2*a Sin[(U + V)/2]*Sin[(U - V)/2], 
      a_. Sin[U_] + a_. Sin[V_] :> 2 a*Sin[(U + V)/2]*Cos[(U - V)/2], 
      a_. Sin[U_] - a_. Sin[V_] :> -2 a*Sin[(U - V)/2]*Cos[(U + V)/2], 
      k_Integer*(B + C) :> k*Pi - k*A, (B + C) :> Pi - A}
    

and

zz = 13 Cos[A] - 8 Cos[3 A] + Cos[5 A] - Cos[B - 5 C] + 
  5 Cos[B - 3 C] - 9 Cos[B - C] - 4 Cos[4 A] Cos[B - C] - 
  Cos[3 (B - C)] + 5 Cos[3 B - C] - Cos[5 B - C] + 8 Cos[3 B + C] - 
  2 Cos[5 B + C] + 8 Cos[B + 3 C] - 2 Cos[B + 5 C]

and

zz //. r0 /. {Cos[x_] :> Cos[Simplify[x]], 
  Sin[x_] :> Sin[Simplify[x]]}

returnes

13 Cos[A] - 8 Cos[3 A] - 9 Cos[B - C] - 4 Cos[4 A] Cos[B - C] - 
 2 Cos[2 (B - 2 C)] Cos[B + C] + 10 Cos[2 (B - C)] Cos[B + C] + 
 16 Cos[B - C] Cos[2 (B + C)] - 4 Cos[2 (B - C)] Cos[3 (B + C)] - 
 2 Sin[1/2 (5 A + 5 B - C)] Sin[1/2 (5 A - 5 B + C)]

which I believe that is closer to what you are looking for

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract