randVar() [BLUE, RED, GREEN] 4 tabulate(function() { return randRangeUniqueNonZero(0, MAX_DEGREE, randRange(1, 3)).sort().reverse(); }, 2) tabulate( function(n) { var coefs = []; for ( var i = 0; i <= MAX_DEGREE; i++ ) { var value = 0; for ( var j = 0; j < NON_ZERO_INDICES[ n ].length; j++ ) { if ( i === NON_ZERO_INDICES[ n ][ j ] ) { value = randRangeNonZero( -7, 7 ); break; } } coefs[ i ] = value; } return new Polynomial( 0, MAX_DEGREE, coefs, X ); }, 2 ) function() { var likeTerms = []; var counter = 0; var areLikeTerms = false; for ( var i = POL_1.minDegree; i <= POL_1.maxDegree; i++ ) { if ( POL_1.coefs[ i ] === 0 ) { continue; } for ( var j = POL_2.minDegree; j <= POL_2.maxDegree; j++ ) { if ( POL_2.coefs[ j ] === 0 ) { continue; } if ( likeTerms[ i + j ] === undefined ) { likeTerms[ i + j ] = ""; } else if ( likeTerms[ i + j ] === "" ) { likeTerms[ i + j ] = COLORS[ counter++ ]; areLikeTerms = true; } } } return areLikeTerms ? likeTerms : false; }() POL_1.multiply(POL_2)

Expand the expression.

`\large{(POL)}`

SOLUTION.parsableText()

First use the distributive property.

`(POL_1.coefs[index1] < 0) ? "-" : (n1 === 0 && n2 === 0) ? "" : "+" abs(POL_1.coefs[index1]) === 1 ? "" : abs(POL_1.coefs[index1]) X^index1 ((POL_2.coefs[index2] === 1) ? "" : (POL_2.coefs[index2] === -1) ? "-" : POL_2.coefs[index2] X^index2)`

Simplify.

`(POL_1.coefs[index1] * POL_2.coefs[index2] < 0) ? "-" : (n1 === 0 && n2 === 0) ? "" : "+" coefficient(abs(POL_1.coefs[index1] * POL_2.coefs[index2]))X^{index1 + index2}`

`SOLUTION`

Identify like terms.

`\color{LIKE_TERMS[index1 + index2 ]} {(POL_1.coefs[index1] * POL_2.coefs[index2] < 0) ? "-" : (n1 === 0 && n2 === 0) ? "" : "+" coefficient(abs(POL_1.coefs[index1] * POL_2.coefs[index2]))X^{index1 + index2}}`

Add the coefficients.

`\color{LIKE_TERMS[SOLUTION.getCoefAndDegreeForTerm(n).degree]} {(SOLUTION.getCoefAndDegreeForTerm(n).coef < 0 || n === 0) ? "" : "+" expr(SOLUTION.expr()[n + 1])}`