# Simplify multinomial trig expansion to fewer linear terms like Wolfram?

I'm mystified as to how Wolfram Alpha's TrigReduce[expr] does its magic, particularly on sums of long products that look like $$A \cos^a(B_1 x) \sin^b(B_2 x) \cos^c (B_3 x) \sin^d (B_4 x) \dots$$

I can get to a linear combination of sines & cosines by using power-reduction and product-to-sum formulas, but this yields wayyy more terms than the original expansion, while Wolfram's method yields way fewer. E.g. $\approx 2500$ vs $59$ (!?). What is the trick?

Here's what I'm able to do on my own, taking one term of a multinomial expansion:

\begin{align} & A \cos^2 (B x) \sin(C x) \sin^2 (D x) \cos(E x) \\ = & \frac{A}{4}\big[1 + \cos(2 B x)\big] \sin(C x) \big[1 - \cos(2 D x)\big] \cos(E x) \\ = & \frac{A}{4} \big[ -\cos(2 B x) \sin(C x) \cos(2 D x) \cos (E x) - \sin(C x) \cos(2 D x) \cos(E x) + \cos(2 B x) \sin(C x) \cos(E x) + \sin(C x) \cos(E x) \big] \end{align}

Then I can perform splits like the following: \begin{align} & \cos(2 B x) \sin(C x) \cos(E x) \\ & = \frac{1}{2}\big[\sin((2B+C)x) - \sin((2B-C)x)\big] \cos(E x) \\ & = \frac{1}{2}\sin((2B+C)x)\cos(Ex) - \frac{1}{2}\sin((2B-C)x)\cos(Ex) \\ & = \frac{1}{4}\big[\sin((2B+C+E)x) + \sin((2B+C-E)x) - \sin((2B-C+E)x) - \sin((2B-C-E)x)\big] \end{align}

This small example fails to demonstrate how the # of terms blows up when recursively applying product-to-sum formulas, suggesting there's more to the story of $\text{TrigReduce}$.

Informally, I'll let $s_n$ denote a sum of $n$ trig functions and $p_n$ denote a product of $n$ trig functions. So the splitting example shown above would be expressed as: $$p_3 = (s_2)p_1 = p_2 + p_2 = s_2 + s_2 = s_4$$

Splitting a term of $6$ trig factors would then be expressed as: \begin{align} p_6 & = (s_2)p_4 = p_5 + p_5 = (s_2)p_3 + (s_2)p_3 = p_4 + p_4 + p_4 + p_4 \\ & = (s_2)p_2 + (s_2)p_2 + (s_2)p_2 + (s_2)p_2 = p_3 \times 8 = s_4 \times 8 \end{align}

In general, it appears that splitting a product of $n$ trig factors using product-to-sum formulas yields $2^{n-1}$ linear terms.

Suppose I want to simplify the following expression: $$(\cos(3x) + \sin(5x) + \cos(7x) + \sin(11x))^6$$

The number of terms in the multinomial expansion is $\binom{6+4-1}{4-1} = 84$. Each term is a product of $6$ trig functions (since the exponents in each term must sum to $6$ according to multinomial theorem). As per the earlier formula, a product of $6$ trig functions splits into $32$ linear terms. Not counting the effect of power reduction (PR) formulae, $84 \cdot 32 = 2688$ linear terms. If my intuition is correct, the effect of PR is no better than product-to-sum conversions, because for each exponent that is cut in half, the entire enclosing term gets duplicated (since there are two terms in a PR formula). So roughly $\approx 2688$ terms is the best I know how to do.

However, TrigReduce applied to same expression spits out a mere 59 linear sin/cos terms (!?!). How is this possible? Is Wolfram doing something tricky across the sums of the product strings?

Would appreciate any clues. I know I've posted a few lame tumbleweeds lately; maybe my allowance of dumb questions is reaching a limit. I wouldn't ask this except it's the missing puzzle-piece in an algorithm.

More significant digits in the initial sin/cos arguments means more combinations of possible argument sums, causing Wolfram's $\text{TrigReduce}$ to output an exploding # of terms. I didn't count exactly, but the number easily approaches the order of the OP estimate, i.e. $\approx\binom{n+t-1}{t-1} 2^{n-1}$.