7 Exercises on factoring and simplifying expressions#19229

Merged
merged 9 commits into from Apr 13, 2012
Select commit
+460 −86
33 exercises/common_factors_of_a_polynomial_1.html
 @@ -0,0 +1,33 @@ + + + + + Common factors of a polynomial 1 + + + +
+
+ {op:"var", args:["x"]} + {op:"var", args:["y"]} + {op:"var", args:["z"]} + genFactoringExercise([2, 3, 5, 7, X, Y, Z], 2, 3) + solveFactoringExercise(PROBLEM.question) +
+
+
+

Factor the following expression by finding the common factors of its terms:

+

format(PROBLEM.question)

+

format(SOLUTION.solution)

+ +
+
• format(value)
• +
+
+
+
+
value
+
+
+ +
34 exercises/common_factors_of_a_polynomial_2.html
 @@ -0,0 +1,34 @@ + + + + + Common factors of a polynomial 2 + + + +
+
+ {op:"var", args:["w"]} + {op:"var", args:["x"]} + {op:"var", args:["y"]} + {op:"var", args:["z"]} + genFactoringExercise([2, 3, 5, 7, W, X, Y, Z], 3, 4) + solveFactoringExercise(PROBLEM.question) +
+
+
+

Factor the following expression by finding the common factors of its terms:

+

format(PROBLEM.question)

+

format(SOLUTION.solution)

+ +
+
• format(value)
• +
+
+
+
+
value
+
+
+ +
62 exercises/factoring_difference_of_squares_3.html
 @@ -0,0 +1,62 @@ + + + + + Factoring difference of squares 3 + + + +
+
+
+
+ randFromArray([2,3,5]) + randRange(2, 6) + randRange(1, 6) + F * A * A + F * -B * B + parse(SQUARE + "x^2" + CONSTANT) + solveFactoringExercise(PROBLEM, {factorDiffOfSquares:true}) + SOLUTION.solution.args[1].args[0].args[0].args[0] + SOLUTION.solution.args[1].args[1].args[1] + + parse(F + "(" + a + "x" + "-" + b + ")(" + a + "x" + "+" + b + ")") + parse(F + "(" + a + "x" + "+" + b + ")(" + a + "x" + "-" + b + ")") + parse(-F + "(" + -a + "x" + "+" + b + ")(" + a + "x" + "+" + b + ")") + parse(-F + "(" + a + "x" + "-" + b + ")(" + -a + "x" + "-" + b + ")") + parse(-F + "(" + a + "x" + "+" + b + ")(" + -a + "x" + "+" + b + ")") + parse(-F + "(" + -a + "x" + "-" + b + ")(" + a + "x" + "-" + b + ")") +
+
+

+ Factor the following expression: +

+

+ format(PROBLEM) +

+
+
+
+ +
+
\$( "div.instruction input" ).val()
+
+ var exprGuess = simplify(parse(guess), simplifyOptions.checkInput); + return (isEqual(exprGuess, SOL1) || isEqual(exprGuess, SOL2) || isEqual(exprGuess, SOL3) || + isEqual(exprGuess, SOL4) || isEqual(exprGuess, SOL5) || isEqual(exprGuess, SOL6)); +
+
+
+
+ \$( "div.instruction input" ).val( guess ); +
+
a factored expression, like (x+1)(x+3)
+
+
+
+
+
value
+
+
+ +
53 exercises/factoring_difference_of_squares_4.html
 @@ -0,0 +1,53 @@ + + + + + Factoring difference of squares 4 + + + + +
+
+
+
+ randFromArray([2,3,5]) + randRange( 2, 6 ) + randRange( 1, 6 ) + randRange( 2, 3 ) + F * A * A + F * -B * B + parse(SQUARE + "x^" + (2*P) + CONSTANT) + solveFactoringExercise(PROBLEM, {factorDiffOfSquares:true}) + [ + format(solveFactoringExercise(PROBLEM, {factorDiffOfSquares:false}).solution), + format(solveFactoringExercise(PROBLEM, {factorDiffOfSquares:"a^2-b^2=(a-b)^2"}).solution), + format(solveFactoringExercise(PROBLEM, {factorDiffOfSquares:"a^2-b^2=(a-b)(b-a)"}).solution), + format(solveFactoringExercise(PROBLEM, {factorDiffOfSquares:"a^2-b^2 = (a^2-b^2)(a^2+b^2)"}).solution), + format(solveFactoringExercise(PROBLEM, {factorDiffOfSquares:true, factorWithDiffOfSquares:"a(b^2-c^2)=(ab-ac)(a+c))"}).solution), + ] +
+
+

+ Factor the following expression: +

+

+ format(PROBLEM) +

+
+

format(SOLUTION.solution)

+
+
• value
• +
+
+
+
+
value
+
+
+ +
107 exercises/factoring_polynomials_3.html
 @@ -0,0 +1,107 @@ + + + + + Factoring polynomials 3 + + + +
+
+
+
+ randRange(2, 9) + randFromArray([-1, 1]) + randFromArrayExclude([3, 5, 7, 9], [a]) + b_sign*b_abs + randFromArrayExclude(getFactors(a * b_abs), [1]) + a + b + a * b / A + getGCD(A, a) + b_sign * getGCD(b_abs, C) + simplify(polynomial([A, B, C], "x"), simplifyOptions.basic) + + parse("(" + F1 + "x+" + F2 + ")(" + A / F1 + "x+" + a / F1 + ")") + parse(F1 + "x(" + A / F1 + "x+" + a / F1 + ")+" + F2 + "(" + b / F2 + "x+" + C / F2 + ")}") + [parse("#{ab} &=& #{A}*#{C} &=& " + (A*C), [GREEN, BLUE, ORANGE]), + parse("#{a}+#{b} &=& #{B} &=& #{" + B, [GREEN, GREEN, PINK])] + +
+
+

+ Factor the following expression: +

+

+ format(PROBLEM, "large") +

+
+
+
+ +
+
jQuery("div.instruction input").val()
+
+ return isEqual(parse(guess), SOLUTION); +
+
+
+
+ jQuery("div.instruction input").val(guess); +
+
a factored expression, like (x+1)(x+2)
+
+
+
+

The expression is of the form + parseFormat("#{A}x^2+#{B}x+#{C}}", [BLUE, PINK, ORANGE]). + You can factor this trinomial by grouping. In this case, + \blue{A}=\blue{A}, \pink{B}=\pink{B}, + \orange{C}=\orange{C} +

+
+
+

To do this, the first step is to find two values + \green{a} and + \green{b}, such that:

+

parseFormat("#{ab} = #{A}*#{C}", [GREEN, BLUE, ORANGE])

+

parseFormat("#{a}+#{b} = #{B}", [GREEN, GREEN, PINK])

+

The next step is to rewrite the + expression as parseFormat("#{A}x^2 + #{a}x + #{b}x + #{C}", [BLUE, GREEN, GREEN, ORANGE]) or + parseFormat("(#{A}x^2 + #{a}x) + (#{b}x + #{C})", [BLUE, GREEN, GREEN, ORANGE]), and factor each term, to + find a common factor.

+
+
+

To apply the first step, you need to find + \green{a} and \green{b} such that:

+

formatGroup(GROUP1, [0,1])

+
+
+

The following values can be used:

+

parseFormat("#{a}=#{" + a + "}", [GREEN, GREEN])
+ parseFormat("#{b}=#{" + b + "}", [GREEN, GREEN])

+
+
+

For the second step, rewrite the expression as:

+

parseFormat("#{" + A + "}x^2+#{" + a + "}x+#{" + b + "}x+#{" + C + "}}", [BLUE, GREEN, GREEN, ORANGE])

+

or

parseFormat("(#{" + A + "}x^2+#{" + a + "}x)+(#{" + b + "}x+#{" + C + "})", [BLUE, GREEN, GREEN, ORANGE])

+

The next step is to factor both terms of the above expression:

+
+
+

+ format(HINT1, {del1factors:true, evalBasicNumOps:true}) +

+
+
+

+ Redistribute the common term to get the answer: +

+

+ format(SOLUTION, simplifyOptions.basic, false, "large") +

+
+
+
+
+
+ +
34 exercises/simplifying_rational_expressions_1.html
 @@ -0,0 +1,34 @@ + + + + + Simplifying rational expressions 1 + + + +
+
+ {op:"var", args:["w"]} + {op:"var", args:["x"]} + {op:"var", args:["y"]} + {op:"var", args:["z"]} + genSimplifyingExpressionsExercise(4, 2, [2, 3, 5, 7], [X, Y], [0, 1, 2, 3]) + solveSimplifyingExpressionsExercise(PROBLEM)--> +
+
+
+

Simplify the following expression:

+

format(PROBLEM)

+

format(SOLUTION.solution)

+ +
+
• format(value)
• +
+
+
+
+
value
+
+
+ +
34 exercises/simplifying_rational_expressions_2.html
 @@ -0,0 +1,34 @@ + + + + + Simplifying rational expressions 2 + + + +
+
+ {op:"var", args:["w"]} + {op:"var", args:["x"]} + {op:"var", args:["y"]} + {op:"var", args:["z"]} + genSimplifyingExpressionsExercise(4, 2, [2, 3, 5, 7], [X, Y], [0, 1, 2, 3], true) + solveSimplifyingExpressionsExercise(PROBLEM) +
+
+
+

Simplify the following expression:

+

format(PROBLEM)

+

format(SOLUTION.solution)

+ +
+
• format(value)
• +
+
+
+
+
value
+
+
+ +
155 utils/factoring-expressions.js
 @@ -21,7 +21,7 @@ return 1; }; - var factorDiffOfSquares = function(MATH, expr, options) { + var factorDiffOfSquares = function(expr, options) { var terms = []; for (var iArg = 0; iArg < 2; iArg++) { var term = {factors: [], occFactors: []}; @@ -61,18 +61,18 @@ } else { var coloredExpr = {op: "-", args: [KhanUtil.exprSetStyle(termA.initial, KhanUtil.PINK), KhanUtil.exprSetStyle(termB.initial, KhanUtil.BLUE)]}; - var initialForm = MATH.parseFormat("#{a^2} - #{b^2}", [KhanUtil.PINK, KhanUtil.BLUE]); - var factoredForm = MATH.parseFormat("(#a + #b)(#a - #b)", [KhanUtil.PINK, KhanUtil.BLUE, KhanUtil.PINK, KhanUtil.BLUE]); - hints.push("

" + MATH.format(coloredExpr) + "

The expression is of the form " + initialForm + + var initialForm = KhanUtil.parseFormat("#{a^2} - #{b^2}", [KhanUtil.PINK, KhanUtil.BLUE]); + var factoredForm = KhanUtil.parseFormat("(#a + #b)(#a - #b)", [KhanUtil.PINK, KhanUtil.BLUE, KhanUtil.PINK, KhanUtil.BLUE]); + hints.push("

" + KhanUtil.format(coloredExpr) + "

The expression is of the form " + initialForm + " which is a difference of two squares so we can factor it as " + factoredForm + "

"); - var strA = MATH.parseFormat("#a", [KhanUtil.PINK]); - var strB = MATH.parseFormat("#b", [KhanUtil.BLUE]); + var strA = KhanUtil.parseFormat("#a", [KhanUtil.PINK]); + var strB = KhanUtil.parseFormat("#b", [KhanUtil.BLUE]); hints.push("

What are the values of " + strA + " and " + strB + "?

"); var varA = {op: "var", args: ["a"]}; var varB = {op: "var", args: ["b"]}; var exprA = {op: "=", args: [varA, {op: "sqrt", args: [termA.initial]}, termA.sqrt], style: KhanUtil.PINK}; var exprB = {op: "=", args: [varB, {op: "sqrt", args: [termB.initial]}, termB.sqrt], style: KhanUtil.BLUE}; - hints.push("

" + MATH.format(exprA) + "

" + MATH.format(exprB) + "

"); + hints.push("

" + KhanUtil.format(exprA) + "

" + KhanUtil.format(exprB) + "

"); hints.push("

Use the values we found for " + strA + " and " + strB + " to complete the factored expression, " + factoredForm + "

"); var coloredFactored = KhanUtil.exprClone(solution); for (var iArg1 = 0; iArg1 < 2; iArg1++) { @@ -81,7 +81,7 @@ coloredFactored.args[iArg1].args[iArg2] = KhanUtil.exprSetStyle(coloredFactored.args[iArg1].args[iArg2], colors[iArg2]); } } - hints.push("

So we can factor the expression as:" + MATH.format(coloredFactored) + ""); + hints.push("

So we can factor the expression as:" + KhanUtil.format(coloredFactored) + ""); } return {solution: solution, hints: hints}; }; @@ -219,13 +219,16 @@ return terms; }; - var genFullExpr = function(factors, foundOccFactors, termsOccFactors) { - var remainingTerms = {op: "+", args: genAllTerms(factors, KhanUtil.initOccArray(factors.length), termsOccFactors)}; - var sharedPart = KhanUtil.genExprFromExpFactors(factors, foundOccFactors); - if (sharedPart === 1) { - return remainingTerms; - } - return {op: "*", args: [sharedPart, remainingTerms]}; + var genFullExpr = function(factors, foundOccFactors, termsOccFactors, markShared) { + var remainingTerms = {op: "+", args: genAllTerms(factors, KhanUtil.initOccArray(factors.length), termsOccFactors)}; + var sharedPart = KhanUtil.genExprFromExpFactors(factors, foundOccFactors); + if (sharedPart === 1) { + return remainingTerms; + } + if (markShared) { + sharedPart = KhanUtil.exprSetStyle(sharedPart, {color: KhanUtil.BLUE}); + } + return {op: "*", args: [sharedPart, remainingTerms]}; }; @@ -261,8 +264,8 @@ return numTotal; }; - var genCdotFactors = function(factors, occFactors) { - var args = genListFactors(factors, occFactors); + var genCdotFactors = function(factors, occFactors, sharedOccFactors, sharedStyle) { + var args = genListFactors(factors, occFactors, sharedOccFactors, sharedStyle); var expr; if (args.length === 1) { return args[0]; @@ -275,23 +278,27 @@ } } - var genDecomposition = function(factors, occFactors) { - var exprLeft = KhanUtil.genExprFromExpFactors(factors, occFactors); - var exprRight = genCdotFactors(factors, occFactors); - return {op: "=", args: [exprLeft, exprRight]}; + var genDecomposition = function(factors, occFactors, sharedOccFactors, sharedStyle) { + var exprLeft = KhanUtil.genExprFromExpFactors(factors, occFactors); + var exprRight = genCdotFactors(factors, occFactors, sharedOccFactors, sharedStyle); + return {op: "=", args: [exprLeft, exprRight]}; }; - var genListFactors = function(factors, occFactors) { - var listFactors = []; - for (var iFactor = 0; iFactor < factors.length; iFactor++) { - for (var iOcc = 0; iOcc < occFactors[iFactor]; iOcc++) { - listFactors.push(factors[iFactor]); - } - } - return listFactors; + var genListFactors = function(factors, occFactors, sharedOccFactors, sharedStyle) { + var listFactors = []; + for (var iFactor = 0; iFactor < factors.length; iFactor++) { + for (var iOcc = 0; iOcc < occFactors[iFactor]; iOcc++) { + var factor = KhanUtil.exprClone(factors[iFactor]); + if ((sharedOccFactors !== undefined) && (iOcc < sharedOccFactors[iFactor])) { + factor = KhanUtil.exprSetStyle(factor, sharedStyle); + } + listFactors.push(factor); + } + } + return listFactors; } - var genHintListFactors = function(MATH, factors, occFactors) { + var genHintListFactors = function(factors, occFactors) { var listFactors = genListFactors(factors, occFactors); var strListFactors = ""; for (var iListedFactor = 0; iListedFactor < listFactors.length; iListedFactor++) { @@ -302,45 +309,48 @@ strListFactors += ", "; } } - strListFactors += "" + MATH.format(KhanUtil.exprSetStyle(listFactors[iListedFactor], KhanUtil.BLUE)) + ""; + strListFactors += "" + KhanUtil.format(KhanUtil.exprSetStyle(listFactors[iListedFactor], {color: KhanUtil.BLUE})) + ""; } + var hint = ""; if (listFactors.length === 1) { - return "

The terms have one common factor: " + strListFactors + ".

"; + return hint + "

The terms have one common factor: " + strListFactors + ".

"; } else { - var gcf = MATH.format(KhanUtil.exprSetStyle(KhanUtil.genExprFromExpFactors(factors, occFactors), KhanUtil.BLUE)); - return "

The terms have these common factors: " + strListFactors + ", so the greatest common factor is " + gcf + ".

"; + var gcf = KhanUtil.format(KhanUtil.exprSetStyle(KhanUtil.genExprFromExpFactors(factors, occFactors), KhanUtil.BLUE)); + return hint + "

The terms have these common factors: " + strListFactors + ", so the greatest common factor is " + gcf + ".

"; } }; - var genHintsDecomposeAllFactors = function(MATH, factors, sharedOccFactors, termsOccFactors) { - var colors = [KhanUtil.PINK, KhanUtil.ORANGE, KhanUtil.GREEN]; - var nbTerms = termsOccFactors.length; - var hints = []; - var expr = {op: "+", args: genAllTerms(factors, sharedOccFactors, termsOccFactors)}; - for (var iTerm = 0; iTerm < nbTerms; iTerm++) { - expr.args[iTerm] = KhanUtil.exprSetStyle(expr.args[iTerm], colors[iTerm]); - } - expr = KhanUtil.simplify(expr, KhanUtil.simplifyOptions.checkInput); + var genHintsDecomposeAllFactors = function(factors, sharedOccFactors, termsOccFactors) { + var colors = [KhanUtil.PINK, KhanUtil.ORANGE, KhanUtil.GREEN]; + var nbTerms = termsOccFactors.length; + var hints = []; + var expr = {op: "+", args: genAllTerms(factors, sharedOccFactors, termsOccFactors)}; + for (var iTerm = 0; iTerm < nbTerms; iTerm++) { + expr.args[iTerm] = KhanUtil.exprSetStyle(expr.args[iTerm], colors[iTerm]); + } + expr = KhanUtil.simplify(expr, KhanUtil.simplifyOptions.checkInput); - hints.push("

" + MATH.format(expr) + "

We start by decomposing each term into a product of its most simple factors.

"); + hints.push("

" + KhanUtil.format(expr) + "

We start by decomposing each term into a product of its most simple factors.

"); - for (var iTerm = 0; iTerm < nbTerms; iTerm++) { - var mergedOccFactors = mergeOccFactors(sharedOccFactors, termsOccFactors[iTerm]); - hints.push("

" + MATH.format(KhanUtil.exprSetStyle(genDecomposition(factors, mergedOccFactors), {color: colors[iTerm]})) + "

"); - } - hints.push(genHintListFactors(MATH, factors, sharedOccFactors)); + for (var iTerm = 0; iTerm < nbTerms; iTerm++) { + var mergedOccFactors = mergeOccFactors(sharedOccFactors, termsOccFactors[iTerm]); + var hint = "

" + KhanUtil.format(KhanUtil.exprSetStyle(genDecomposition(factors, mergedOccFactors), {color: colors[iTerm]})) + "

"; + hint += ""; + hints.push(hint); + } + hints.push(genHintListFactors(factors, sharedOccFactors)); - hints.push("

We can rewrite the expression as: " + MATH.format({op: "+", args: genAllTermsMarkShared(factors, sharedOccFactors, termsOccFactors, colors)}) + ".

"); - hints.push("

We now rewrite the expression as a product: " + MATH.format(genFullExpr(factors, sharedOccFactors, termsOccFactors)) + ".

"); - return hints; + hints.push("

We can rewrite the expression as: " + KhanUtil.format({op: "+", args: genAllTermsMarkShared(factors, sharedOccFactors, termsOccFactors, colors)}) + ".

"); + hints.push("

We now rewrite the expression as a product: " + KhanUtil.format(genFullExpr(factors, sharedOccFactors, termsOccFactors, true)) + ".

"); + return hints; }; var mergeOccFactors = function(occFactors1, occFactors2) { - var mergedOccFactors = KhanUtil.initOccArray(occFactors1.length); - for (var iFactor = 0; iFactor < occFactors1.length; iFactor++) { - mergedOccFactors[iFactor] = occFactors1[iFactor] + occFactors2[iFactor]; - } - return mergedOccFactors; + var mergedOccFactors = KhanUtil.initOccArray(occFactors1.length); + for (var iFactor = 0; iFactor < occFactors1.length; iFactor++) { + mergedOccFactors[iFactor] = occFactors1[iFactor] + occFactors2[iFactor]; + } + return mergedOccFactors; }; var removeSharedFactors = function(sharedOccFactors, termsOccFactors) { @@ -352,18 +362,18 @@ } }; - var solveDiffOfSquaresExercise = function(MATH, expr, options) { + var solveDiffOfSquaresExercise = function(expr, options) { if (KhanUtil.exprIsNumber(expr) || (expr.args.length != 2)) { return undefined; } if (expr.op === "-") { var sumExpr = {op: "+", args: [expr.args[0], {op: "-", args: [expr.args[1]]}]}; - return solveDiffOfSquaresExercise(MATH, sumExpr, options); + return solveDiffOfSquaresExercise(sumExpr, options); } - return factorDiffOfSquares(MATH, expr, options); + return factorDiffOfSquares(expr, options); }; - var solveFactoringExercise = function(MATH, expr, options) { + var solveFactoringExercise = function(expr, options) { if (options === undefined) { options = {}; } @@ -373,26 +383,26 @@ var sharedOccFactors = exprFactors.sharedOccFactors; var termsOccFactors = exprFactors.termsOccFactors; - var hints = ["

To factor this expression, we start by looking at the different terms of the sum, and find all of their common factors. We can then rewrite the expression as a product between these common factors, and what's left of the different terms once we remove these factors.

"]; + var hints = ["

To factor this expression, we start by looking at the different terms of the sum and find all of their common factors. We can then rewrite the expression as a product between these common factors and what's left of the different terms once we remove these factors.

"]; - var detailedHints = genHintsDecomposeAllFactors(MATH, factors, sharedOccFactors, termsOccFactors); + var detailedHints = genHintsDecomposeAllFactors(factors, sharedOccFactors, termsOccFactors); var solution = genFullExpr(factors, sharedOccFactors, termsOccFactors); if (options.factorDiffOfSquares) { var hint = "

We obtain the following expression: " + KhanUtil.getSubHints("common-factors", "Show explanation", detailedHints); - hint += "

" + MATH.format(solution) + "

"; + hint += "

" + KhanUtil.format(solution) + "

"; hints.push(hint); hints.push("

Can we factor this expression even more?

"); for (var iArg = 0; iArg < solution.args.length; iArg++) { var arg = solution.args[iArg]; - var solvedArg = solveDiffOfSquaresExercise(MATH, arg, options); + var solvedArg = solveDiffOfSquaresExercise(arg, options); if (solvedArg === undefined) { continue; } - hints.push("

This part of the expression can be factored: " + MATH.format(arg) + "

"); + hints.push("

This part of the expression can be factored: " + KhanUtil.format(arg) + "

"); var hint = "

We recognize and factor a difference of squares, and obtain the following expression: " + KhanUtil.getSubHints("diff-squares-" + iArg, "Show explanation", solvedArg.hints); solution.args[iArg] = solvedArg.solution; - hint += "

" + MATH.format(solution); + hint += "

" + KhanUtil.format(solution); hints.push(hint); } } else { @@ -409,7 +419,7 @@ } else if (options.factorWithDiffOfSquares === "(ab^2-cd^2)=a(b - d)(b + d)") { } - hints.push("

There is nothing left to factor using this approach. The answer is : " + MATH.format(solution) + "

"); + hints.push("

There is nothing left to factor using this approach. The answer is : " + KhanUtil.format(solution) + "

"); return {hints: hints, solution: solution}; }; @@ -486,7 +496,7 @@ return choices; }; - var genFactoringExercise = function(MATH, factors, nbTerms, factorsPerTerm) { + var genFactoringExercise = function(factors, nbTerms, factorsPerTerm) { var sharedFactors = []; var sharedOccFactors = KhanUtil.initOccArray(factors.length); var numTotal = genSharedFactors(factors, sharedFactors, sharedOccFactors, factorsPerTerm); @@ -509,5 +519,12 @@ factorSum: factorSum, genFullExpr: genFullExpr }); + + \$.fn["factoring-expressions"] = function(problem) { + return this.find(".factoring-expressions").andSelf().filter(".factoring-expressions").each(function() { + \$(".orig-hint").hide(); + \$(".new-hint").show(); + }); + }; })();
34 utils/simplifying-expressions.js
 @@ -79,24 +79,24 @@ return {op: "dfrac", args: newArgs}; }; - var addInitialSteps = function(MATH, steps) { + var addInitialSteps = function(steps) { var aExpr = {op: "var", args: ["a"]}; var exampleFactors = [3, 5, aExpr, {op: "var", args: ["b"]}, {op: "var", args: ["c"]}]; var exampleOldOccs = [[1, 0, 2, 1, 0], [0, 1, 1, 0, 1]]; var exampleNewOccs = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1]]; var exampleExprInit = getFractionFromOccFactors(exampleFactors, exampleOldOccs); var exampleExprStep = getFractionFromOccFactors(exampleFactors, exampleNewOccs, exampleOldOccs); var exampleExprEnd = getFractionFromOccFactors(exampleFactors, exampleNewOccs); - var exampleGroup = [MATH.parse("#{\\dfrac{a^2}{a}} &= #{\\dfrac{#{a} \\cdot a}{#{a}}}", [KhanUtil.BLUE, KhanUtil.BLUE, {cancel: true}, {cancel: true}]), - MATH.parse("&= #{\\dfrac{a}{1}}", [KhanUtil.BLUE]), - MATH.parse("&= #{a}", [KhanUtil.BLUE])]; + var exampleGroup = [KhanUtil.parse("#{\\dfrac{a^2}{a}} &= #{\\dfrac{#{a} \\cdot a}{#{a}}}", [KhanUtil.BLUE, KhanUtil.BLUE, {cancel: true}, {cancel: true}]), + KhanUtil.parse("&= #{\\dfrac{a}{1}}", [KhanUtil.BLUE]), + KhanUtil.parse("&= #{a}", [KhanUtil.BLUE])]; steps.add("

To simplify this type of expression, we need to look for factors that are shared by both the numerator and the denominator.

For each such factor, if it is present with the same exponent both at the numerator and the denominator, then we can remove that factor completely. If the exponent is different, then we remove the one with the lowest exponent, and substract it from the one with the higher exponent.

"); - var subHints = ["

Why can we simplify an expression this way? Let's look at the detailed steps that we imply when we write " + MATH.format(exampleExprStep) + " :

" + MATH.format(exampleExprInit) + " can be rewritten as " + - MATH.parseFormat("\\dfrac{3}{5} \\cdot #{\\dfrac{a^2}{a}} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE]) + "

" + - MATH.formatGroup(exampleGroup) + "

So we get " + - MATH.parseFormat("\\dfrac{3}{5} \\cdot #{a} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE]) + ", or " + - MATH.parseFormat("\\dfrac{3ab}{5c}") + ""]; - steps.add("

For example, if we had this expression: " + MATH.format(exampleExprInit) + ", we would see that the factor " + MATH.format(aExpr) + " is present in both the numerator and the denominator.

We would then simplify it like this: " + MATH.format(exampleExprStep) + " and obtain: " + MATH.format(exampleExprEnd) + " " + KhanUtil.getSubHints("factoring", "Show explanation", subHints) + "

Can you apply this technique to this exercise?

"); + var subHints = ["

Why can we simplify an expression this way? Let's look at the detailed steps that we imply when we write " + KhanUtil.format(exampleExprStep) + " :

" + KhanUtil.format(exampleExprInit) + " can be rewritten as " + + KhanUtil.parseFormat("\\dfrac{3}{5} \\cdot #{\\dfrac{a^2}{a}} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE]) + "

" + + KhanUtil.formatGroup(exampleGroup) + "

So we get " + + KhanUtil.parseFormat("\\dfrac{3}{5} \\cdot #{a} \\cdot b \\cdot \\dfrac{1}{c}", [KhanUtil.BLUE]) + ", or " + + KhanUtil.parseFormat("\\dfrac{3ab}{5c}") + ""]; + steps.add("

For example, if we had this expression: " + KhanUtil.format(exampleExprInit) + ", we would see that the factor " + KhanUtil.format(aExpr) + " is present in both the numerator and the denominator.

We would then simplify it like this: " + KhanUtil.format(exampleExprStep) + " and obtain: " + KhanUtil.format(exampleExprEnd) + " " + KhanUtil.getSubHints("factoring", "Show explanation", subHints) + "

Can you apply this technique to this exercise?

"); }; var factorNumeratorDenominator = function(expr, options, steps) { @@ -129,11 +129,11 @@ } return newExpr; }; - var solveSimplifyingExpressionsExercise = function(MATH, expr) { + var solveSimplifyingExpressionsExercise = function(expr) { var steps = new KhanUtil.StepsProblem([], expr, "simplify by factoring"); - addInitialSteps(MATH, steps); + addInitialSteps(steps); var subSteps = new KhanUtil.StepsProblem([], expr, "factor numerator and denominator"); - var options = {evalBasicNumOps: true, simplifyMode: "factor"}; + var options = KhanUtil.simplifyOptions.factor; var newExpr = factorNumeratorDenominator(expr, options, subSteps); if (KhanUtil.stepIsUsed(subSteps)) { steps.add("The first step is to factor the numerator and denominator, if possible : " + @@ -178,10 +178,10 @@ var hintExpr = getFractionFromOccFactors(factors, newOccFactors, argsOccFactors); if (KhanUtil.exprIdentical(newExpr, solExpr)) { - steps.add("

There are no factors that can be simplified in this expression, so the answer is: " + MATH.format(solExpr) + ""); + steps.add("

There are no factors that can be simplified in this expression, so the answer is: " + KhanUtil.format(solExpr) + ""); } else { - steps.add("

Applying the approach described above gives in this case:

" + MATH.format(hintExpr) + "

We obtain the following expression:

" + MATH.format(solExpr) + "