# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
121 lines (107 sloc) 5.29 KB
randVar() [ BLUE, ORANGE, GREEN ] 7 randRangeUniqueNonZero( 0, MAX_DEGREE, randRange(2, 3) ).sort().reverse() tabulate( function() { var coefs = []; for ( var i = 0; i <= MAX_DEGREE; i++ ) { var value = 0; for ( var j = 0; j < NON_ZERO_INDICES.length; j++ ) { if ( i === NON_ZERO_INDICES[ j ] ) { value = randRangeNonZero( -7, 7 ); break; } } coefs[ i ] = value; } return new Polynomial( 0, MAX_DEGREE, coefs, X ); }, 2 )

Simplify the expression.

(POL_1) SIGN (POL_2)

SOLUTION

• POL_1.subtract( POL_2 )
"-" POL_1.subtract( POL_2 ) getFakeAnswers( SOLUTION )

Since this is subtraction, when removing the parenthesis we must distribute the minus sign to all terms in the second polynomial.

POL_2 = POL_2.multiply( -1 ), null

POL_1 + POL_2

Since this is addition, we can remove the parenthesis without any extra steps.

POL_1 + POL_2

Identify like terms.

( POL.coefs[ index ] < 0 ) ? "-" : ( n === 0 && POL === POL_1 ) ? "" : "+"\color{COLORS[ n ]}{abs( POL.coefs[ index ] ) === 1 ? "" : abs( POL.coefs[ index ] )X^index}

Combine like terms.

+\color{COLORS[ n ]}{(POL_1.coefs[ index ] + POL_2.coefs[ index ])X^index}