# Trigonometry expansion of a product

The following command does what I want:

TrigExpand[ Cos[a + b]^2]

(* 1/2 + 1/2 Cos[a]^2 Cos[b]^2 - 1/2 Cos[b]^2 Sin[a]^2 -
2 Cos[a] Cos[b] Sin[a] Sin[b] - 1/2 Cos[a]^2 Sin[b]^2 +
1/2 Sin[a]^2 Sin[b]^2 *)


Unfortunately, it does not apply the distributive property of the product in another case, that is the one I am interested in:

TrigExpand[ Cos[c*(a + b)]^2]

(*  Cos[c*(a + b)]^2  *)


How can I tell Mathematica to do that initial step?

-
Try TrigReduce[Cos[c*(a + b)]^2], it yields 1/2 (1 + Cos[2 (a + b) c]) – Artes Jul 16 '13 at 18:11
Sure, but that's not the result I want, which must be in terms of Cos[ac] and Sin[bc], like the first one above. – flebool Jul 16 '13 at 18:24

With some clarification in the comments you expect the result in terms of Sin[a c] and Cos[a c]. For this purpose one can use MapAll (a shorthand //@). It is not so common as Map (/@) but sometimes it can be very handy:

TrigExpand //@ ( Cos[c (a + b)]^2)

1/2 + 1/2 Cos[a c]^2 Cos[b c]^2 - 1/2 Cos[b c]^2 Sin[a c]^2
- 2 Cos[a c] Cos[b c] Sin[a c] Sin[b c] - 1/2 Cos[a c]^2 Sin[b c]^2
+ 1/2 Sin[a c]^2 Sin[b c]^2

-
you get the endresult if you use MapAll in its non-shorthand form...MapAll[TrigExpand, Cos[c (a + b)]^2] – Stefan Jul 16 '13 at 19:55
Thanks, both of you, Map and MapAll will be useful in many situations. For curiosity, do you know why the non-shorthand form behaves differently? – flebool Jul 16 '13 at 21:00
@Stefan It hasn't been the reason, just only overlooked braces (). Thanks for pointing it out. – Artes Jul 16 '13 at 22:17
@flebool Look at the edit, the shorthand form works correctly. – Artes Jul 16 '13 at 22:18
@Artes ah. ok :) i've overseen it as well...was already confused about the different results. – Stefan Jul 16 '13 at 22:24

Artes' method is pleasingly concise, because it uses TrigExpand to expand c*(a + b) to a c + b c by mapping it to that specific part. Another approach is to use ExpandAll:

ExpandAll[expr] expands out all products and integer powers in any part of expr.

Cos[c*(a + b)]^2 // ExpandAll // TrigExpand

1/2 + 1/2 Cos[a c]^2 Cos[b c]^2 - 1/2 Cos[b c]^2 Sin[a c]^2 -
2 Cos[a c] Cos[b c] Sin[a c] Sin[b c] - 1/2 Cos[a c]^2 Sin[b c]^2 +
1/2 Sin[a c]^2 Sin[b c]^2


This may be somewhat faster on large expressions.

-