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?Positive x_.] :> Sin[x] Cos[(n-1)x] + Sin[(n-1)x] Cos[x],
	Cos[n_Integer?Positive x_.] :> Cos[x] Cos[(n-1)x] - Sin[x] Sin[(n-1)x]
}

SetAttributes[TrigArgument, Listable]

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

End[]

Protect[ TrigArgument ]

EndPackage[]
