BeginPackage["CSM`TrigArgument`"]

TrigArgument::usage = "TrigArgument[e] writes trigonometric functions
	of sums and products as products of simple trigonometric functions."

Begin["`Private`"]

trigArgumentRules = {
	Sin[x_ + y_] :> Sin[x] Cos[y] + Sin[y] Cos[x],
	Cos[x_ + y_] :> Cos[x] Cos[y] - Sin[x] Sin[y],
	Sin[n_Integer?EvenQ x_.] :>
		Sin[n/2 x] Cos[n/2 x] + Sin[n/2 x] Cos[n/2 x],
	Sin[n_Integer?OddQ x_.] :>
		Sin[(n+1)/2 x] Cos[(n-1)/2 x] + Sin[(n-1)/2 x] Cos[(n+1)/2 x],
	Cos[n_Integer?EvenQ x_.] :>
		Cos[n/2 x] Cos[n/2 x] - Sin[n/2 x] Sin[n/2 x],
	Cos[n_Integer?OddQ x_.] :>
		Cos[(n+1)/2 x] Cos[(n-1)/2 x] - Sin[(n+1)/2 x] Sin[(n-1)/2 x]
}

SetAttributes[TrigArgument, Listable]

TrigArgument[expr_] :=
	Together[ FixedPoint[ Function[e, e //. trigArgumentRules], expr ] ]

End[]

Protect[ TrigArgument ]

EndPackage[]
