# Sum to Product Trig Identities

All,

I was enjoying sum to product trig identities in Mathematica, smiling that it was going well, producing the same answers trig students get by hand.

Sin[α] + Sin[β] // TrigFactor


2 Cos[α/2 - β/2] Sin[α/2 + β/2]


And my first example:

Sin[5 θ] - Sin[3 θ] // TrigFactor // Simplify


2 Cos[4 θ] Sin[θ]


But then:

Cos[3 θ] + Cos[2 θ] // TrigFactor // Simplify


2 Cos[θ/2]^2 (1 - 2 Cos[θ] + 2 Cos[2 θ])


Where the expected answer is $2\cos\frac{5\theta}{2}\cos\frac{\theta}{2}$.

Suggestions?

• This doesn't really help but it is at least satisfying to note that 2 Cos[(5 \[Theta])/2] Cos[ \[Theta]/2] // TrigReduce results in Cos[2 \[Theta]] + Cos[3 \[Theta]] Oct 8, 2015 at 19:11

As the TrigFactor help page says under Possible issues:

A trigonometric expression can be factored in many different ways

Looking at the Wikipedia page of trigonometric identies you can find many identities that can apply. For instance, there are double and triple angle identities that seem directly relevant in your Cos[3 θ] + Cos[2 θ] case.

If you want Mathematica to use a specific identity you could define a rule of your own:

cosSum = Cos[a_] + Cos[b_] :> 2 Cos[(a + b)/2] Cos[(a - b)/2];

Cos[3 θ] + Cos[2 θ] /. cosSum
(* 2 Cos[θ/2] Cos[(5 θ)/2] *)


In slightly more complex situations this might apply differently than you intended:

Cos[p] + Cos[3 θ] + Cos[2 θ] /. cosSum
(* Cos[3 θ] + 2 Cos[1/2 (p - 2 θ)] Cos[1/2 (p + 2 θ)] *)


Mathematica picks the first match it can find, but because p is not evidently related to 2 θ that doesn't yield a very useful result.

Let's define a rule that only applies if the two cosines have arguments that are integer multiples of a common term:

cosSumMul = Cos[a_] + Cos[b_] /; Head[a/b] == Rational :> 2 Cos[(a + b)/2] Cos[(a - b)/2];


Applying the modified rule:

Cos[p] + Cos[3 θ] + Cos[2 θ] /. cosSumMul
(* Cos[p] + 2 Cos[θ/2] Cos[(5 θ)/2] *)


Different order:

Cos[3 θ] + Cos[p] + Cos[2 θ] /. cosSumMul
(* Cos[p] + 2 Cos[θ/2] Cos[(5 θ)/2] *)

• Fabulous answer, applying the specific identity you want. Thanks. Oct 8, 2015 at 20:33
• For reference: the identity used by Sjoerd is one of the prosthaphaeresis formulae. Oct 8, 2015 at 22:30