randRangeWeightedExclude(1, 3, 1, 0.8, [0]) randRange(1, 3) randRange(3, 4) randRange(1, EXPONENT) EXPONENT === WHICH_TERM ? "x" : "x^{" + (EXPONENT - WHICH_TERM + 1) + "}" pow(TERM1_COEF, EXPONENT - WHICH_TERM + 1) * choose(EXPONENT, WHICH_TERM - 1) * pow(TERM2, WHICH_TERM - 1)

What is the coefficient of TERM_STRING in the expansion of (expr(["*", TERM1_COEF, "x"]) + TERM2)^{EXPONENT}?

SOLUTION

Rather than multiplying out (expr(["*", TERM1_COEF, "x"]) + TERM2)^{EXPONENT}, we can use the binomial theorem to list all the coefficients.

Write out all the terms of the expansion. What are the binomial coefficients for each term? (Though we really just care about the \pink{TERM_STRING} term)

\blue{?} \cdot \pink{ ( expr(["*", TERM1_COEF, "x"]) ) ^{ EXPONENT - TERM} } TERM2^{TERM} +

The binomial theorem indicates that the coefficient to the k^{th} term (k going from 0 to EXPONENT) is \binom{EXPONENT}{k}. [What does this mean?]

\binom{n}{k} is an expression which indicates a set of n elements combined k at a time ("n choose k"). \binom{n}{k} = \dfrac{n!}{k!(n-k)!}

\blue{\binom{EXPONENT}{TERM}} \pink{ ( expr(["*", TERM1_COEF, "x"]) ) ^{ EXPONENT - TERM} } TERM2^{TERM} +

[How would I do this with Pascal's Triangle?]

You can use the EXPONENT + 1^{th} row (one more than the exponent) of Pascal's triangle to find the binomial coefficients:

init({ range: [ [-EXPONENT/2 - 0.5, EXPONENT/2 + 0.5], [-EXPONENT - 0.5, 0.5] ] }); _(EXPONENT + 1).times(function(n) { _(n + 1).times(function(k) { label([k - n/2, -n], choose(n, k), { color: n === EXPONENT ? BLUE : "black" }); }); });

These values can replace the combinatorial terms in the equation above.

Expand:

\blue{choose(EXPONENT, TERM)} \cdot \pink{ ( expr(["*", TERM1_COEF, "x"]) ) ^{ EXPONENT - TERM} } TERM2^{TERM} +

Simplify:

\qquad \pink{ pow(TERM1_COEF, EXPONENT - TERM) * choose(EXPONENT, TERM) * pow(TERM2, TERM) x^{EXPONENT - TERM} x } +

The coefficient of \pink{TERM_STRING} is \pink{SOLUTION}.