# Khan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Rewrite absolute_value_equations to not use multiple choice

Summary: CCing Emily since you might appreciate the interesting answer type hack

Test Plan: Tested locally

Reviewers: stephanie

Reviewed By: stephanie

CC: emily

Differential Revision: http://phabricator.khanacademy.org/D958
commit 3a9c2f13cd1b88e03cc3bbfe439367d0ea77c7ae 1 parent 103deac
beneater authored
Showing with 431 additions and 236 deletions.
1. +431 −236 exercises/absolute_value_equations.html
667 exercises/absolute_value_equations.html
 @@ -4,90 +4,41 @@ Absolute value equations +
-
- randRange(2, 8) - randRangeNonZero(-10, 10) - randRangeNonZero(-6, 6) - randRange(2, 10) - randRangeNonZero(-10, 10) - abs(A-C) - fractionReduce(D-B, A-C) - (D-B)/(A-C) > 0 - abs((A-C)/getGCD(D-B, A-C)) - - (function() { - if ((D-B)/(A-C) > 0) { - return fractionReduce(abs(D-B)-E*abs(A-C), abs(A-C)); - } else { - return "No solution"; - } - })() - - - (function() { - if ((D-B)/(A-C) > 0) { - return fractionReduce(-1*abs(D-B)-E*abs(A-C), abs(A-C)); - } else { - return "No solution"; - } - })() - - - (function() { - if ((D-B)/(A-C) > 0) { - return "<code>" - +"x = " - +fractionReduce(-1*abs(D-B)-E*abs(A-C), abs(A-C)) - +"\\text{ or }" - +"x = " - +fractionReduce(abs(D-B)-E*abs(A-C), abs(A-C)) - +"</code>"; - } else { - return "No solution"; - } - })() - - - (function() { - var choices = []; - - for (var i = 0; i < 4; i++) { - var choice = "<code>"; - var nOffset = randRange(1, 10); - var dOffset = randRangeExclude(1, 10, [ C-A ]); - var tOffset = randRange(1, 10); - if (D-B+nOffset === 0 && E+tOffset === 0) { - choice += "x = 0"; - } else { - choice += "x = " - +fractionReduce(-1*abs(D-B+nOffset)-(E+tOffset)*abs(A-C+dOffset), abs(A-C+dOffset)) - +"\\text{ or }" - +"x = " - +fractionReduce(abs(D-B+nOffset)-(E+tOffset)*abs(A-C+dOffset), abs(A-C+dOffset)); - } - choice += "</code>"; - choices.unshift(choice); - } - - if ((D-B)/(A-C) > 0) { - choices.shift(); - choices.unshift(SOLUTION); - choices = shuffle(choices); - choices.push("No solution"); - } else { - choices = shuffle(choices); - choices.push(SOLUTION); - } - - return choices; - })() -
-
-
+
+
+ randRange(2, 8) + randRangeNonZero(-10, 10) + + randRangeNonZero(-6, 6) + + randRange(2, 10) + randRangeNonZero(-10, 10) + (D - B) / (A - C) <= 0 + + [abs(D - B) - E * abs(A - C), abs(A - C)] + + + [-1 * abs(D - B) - E * abs(A - C), abs(A - C)] + + NO_SOLUTION ? [] : [ + POS_SOLUTION[0] / POS_SOLUTION[1], + NEG_SOLUTION[0] / NEG_SOLUTION[1] + ] + fractionReduce(D - B, A - C) + + abs((A - C) / getGCD(D - B, A - C)) + +
+

Solve for x:

@@ -97,171 +48,415 @@

-

SOLUTION

- -
-
• choice
• -
-
-
- -
-
-
-

C > 0 ? "Subtract" : "Add" abs(C)|x + E| C > 0 ? "from" : "to" both sides:

-

- (A|x + E| + B) - C|x + E| = - (C|x + E| + D) - C|x + E| -

-

- A - C|x + E| + B = D -

-
-
-

B > 0 ? "Subtract" : "Add" abs(B) B > 0 ? "from" : "to" both sides:

-

- (A - C|x + E| + B) - B = - D - B -

-

- A - C|x + E| = D - B -

-
-
-

Divide both sides by A - C.

-

- \dfrac{A - C|x + E|}{A - C} = - fraction(D-B, A-C) -

-
-
-

Simplify.

-

|x + E| = SIMPLIFIED

-
-
-
-

Because the absolute value of an expression is its distance from zero, it has two solutions, one negative and one positive:

-

x + E = - SIMPLIFIED

-

or

-

x + E = SIMPLIFIED

-
-
-

Calculate the solution where x + E is negative.

-

x + E = - SIMPLIFIED

-
-
-

E > 0 ? "Subtract" : "Add" abs(E) E > 0 ? "from" : "to" both sides:

-

x + E - E = - SIMPLIFIED - E

-

x = - SIMPLIFIED - E

-
-
-

Change the term to an equivalent fraction with a denominator of SIMPLIFIED_DENOM.

-

x = - SIMPLIFIED - E\cdot fraction(SIMPLIFIED_DENOM,SIMPLIFIED_DENOM)

-

x = - SIMPLIFIEDE > 0 ? "-" : "+" fraction(abs(E)*SIMPLIFIED_DENOM,SIMPLIFIED_DENOM)

-
-
-

x = NEG_RESULT

+
+
+
+ SOLUTION +
+

+ x = +   or + x = +

+

-

Then calculate the solution where x + E is positive.

-

x + E = SIMPLIFIED

+
-
-

E > 0 ? "Subtract" : "Add" abs(E) E > 0 ? "from" : "to" both sides:

-

x + E - E = SIMPLIFIED - E

-

x = SIMPLIFIED - E

-
-
-

Change the term to an equivalent fraction with a denominator of SIMPLIFIED_DENOM.

-

x = SIMPLIFIED - E\cdot fraction(SIMPLIFIED_DENOM,SIMPLIFIED_DENOM)

-

x = SIMPLIFIEDE > 0 ? "-" : "+" fraction(abs(E)*SIMPLIFIED_DENOM,SIMPLIFIED_DENOM)

-
-
-

x = POS_RESULT

+ +
+
+ $("#solutionarea input").eq(0).val() === "" + && +$("#solutionarea input").eq(1).val() === "" + && + !\$("#solutionarea input").eq(2).is(":checked") +
+
+ return guess ? "" : true; +
+ + one or two integers, like 6 + + + one or two simplified proper fractions, like + 3/5 + + + one or two simplified improper fractions, like + 7/4 + + + one or two exact decimals, like + 0.75 + + + if there is no solution for x, leave the + boxes blank and check "No solution" +
-
-
-
-

A > 0 ? "Subtract" : "Add" A|x + E| A > 0 ? "from" : "to" both sides:

-

- (A|x + E| + B) - A|x + E| = - (C|x + E| + D) - A|x + E| -

-

- B = C - A|x + E| + D -

-
-
-

D > 0 ? "Subtract" : "Add" abs(D) D > 0 ? "from" : "to" both sides:

-

- B - D = - (C - A|x + E| + D) - D -

-

- B - D = C - A|x + E| -

-
-
-

Divide both sides by C - A.

-

- fraction(B-D, C-A) = - \dfrac{C - A|x + E|}{C - A} -

-
-
-

Simplify.

-

SIMPLIFIED = |x + E|

-
-
-
-

Because the absolute value of an expression is its distance from zero, it has two solutions, one negative and one positive:

-

- SIMPLIFIED = x + E

-

or

-

SIMPLIFIED = x + E

-
-
-

Calculate the solution where x + E is negative.

-

- SIMPLIFIED = x + E

-
-
-

E > 0 ? "Subtract" : "Add" abs(E) E > 0 ? "from" : "to" both sides:

-

- SIMPLIFIED - E = x + E - E

-

- SIMPLIFIED - E = x

-
-
-

Change the term to an equivalent fraction with a denominator of SIMPLIFIED_DENOM.

-

- SIMPLIFIED - E\cdotfraction(SIMPLIFIED_DENOM,SIMPLIFIED_DENOM) = x

-

- SIMPLIFIEDE > 0 ? "-" : "+" fraction(abs(E)*SIMPLIFIED_DENOM,SIMPLIFIED_DENOM) = x

-
-
-

NEG_RESULT = x

-
-
-

Then calculate the solution where x + E is positive.

-

SIMPLIFIED = x + E

-
-
-

E > 0 ? "Subtract" : "Add" abs(E) E > 0 ? "from" : "to" both sides:

-

SIMPLIFIED - E = x + E - E

-

SIMPLIFIED - E = x

-
-
-

Change the term to an equivalent fraction with a denominator of SIMPLIFIED_DENOM.

-

SIMPLIFIED - E\cdot fraction(SIMPLIFIED_DENOM,SIMPLIFIED_DENOM) = x

-

SIMPLIFIEDE > 0 ? "-" : "+" fraction(abs(E)*SIMPLIFIED_DENOM,SIMPLIFIED_DENOM) = x

+ +
+
+
+

+ C > 0 ? "Subtract" : "Add" + + \red{abs(C)|x + E|} + + C > 0 ? "from" : "to" both sides: +

+

\qquad\begin{eqnarray} + A|x + E| + B + &=& + C|x + E| + D + \\ \\ + \red{ - C|x + E|} + && + \red{ - C|x + E|} \\ \\ + A - C|x + E| + + B + &=& D + \end{eqnarray} +

+
+
+

+ B > 0 ? "Subtract" : "Add" + \red{abs(B)} + B > 0 ? "from" : "to" both sides: +

+

\qquad\begin{eqnarray} + A - C|x + E| + + B &=& D \\ \\ + \red{ - B} &=& + \red{ - B} \\ \\ + A - C|x + E| &=& + D - B + \end{eqnarray} +

+
+
+

+ Divide both sides by + \red{A - C}: +

+

\qquad + \dfrac{A - C|x + E|} + {\red{A - C}} = + \dfrac{D - B} + {\red{A - C}} +

+
+
+

Simplify:

+

+ \qquad |x + E| = + SIMPLIFIED +

+
+
+
+

+ Because the absolute value of an expression + is its distance from zero, it has two + solutions, one negative and one positive: +

+

\qquad + x + E = -SIMPLIFIED +

+

or

+

\qquad + x + E = SIMPLIFIED +

+
+
+

+ Solve for the solution where + x + E is negative: +

+

\qquad + x + E = -SIMPLIFIED +

+
+
+

+ E > 0 ? "Subtract" : "Add" + \red{abs(E)} + E > 0 ? "from" : "to" both + sides: +

+

\qquad\begin{eqnarray} + x + E &=& + -SIMPLIFIED \\ \\ + \red{- E} && + \red{- E} \\ \\ + x &=& -SIMPLIFIED - + E + \end{eqnarray} +

+
+
+

+ Change the + \red{{} - E} + to an equivalent fraction with a + denominator of + SIMPLIFIED_DENOM: +

+

\qquad + x = - SIMPLIFIED + \red{E > 0 ? "-" : "+" + fraction(abs(E) * SIMPLIFIED_DENOM, + SIMPLIFIED_DENOM)} +

+
+

\qquad + x = fractionReduce.apply(null, + NEG_SOLUTION) +

+
+

+ Then calculate the solution where + x + E is positive: +

+

\qquad + x + E = SIMPLIFIED +

+
+
+

+ E > 0 ? "Subtract" : "Add" + \red{abs(E)} + E > 0 ? "from" : "to" both + sides: +

+

\qquad\begin{eqnarray} + x + E &=& + SIMPLIFIED \\ \\ + \red{- E} && + \red{- E} \\ \\ + x &=& SIMPLIFIED - + E + \end{eqnarray} +

+
+
+

+ Change the + \red{{} - E} + to an equivalent fraction with a + denominator of + SIMPLIFIED_DENOM: +

+

\qquad + x = SIMPLIFIED + \red{E > 0 ? "-" : "+" + fraction(abs(E) * SIMPLIFIED_DENOM, + SIMPLIFIED_DENOM)} +

+
+

\qquad + x = fractionReduce.apply(null, + POS_SOLUTION) +

+
-
-

POS_RESULT = x

+
+
+

+ A > 0 ? "Subtract" : "Add" + + \red{A|x + E|} + + A > 0 ? "from" : "to" both sides: +

+

\qquad\begin{eqnarray} + A|x + E| + B + &=& + C|x + E| + D + \\ \\ \red{- A|x + E|} + && + \red{- A|x + E|} \\ \\ + B &=& + C - A|x + E| + + D + \end{eqnarray} +

+
+
+

+ D > 0 ? "Subtract" : "Add" + abs(D) + D > 0 ? "from" : "to" both sides: +

+

\qquad\begin{eqnarray} + B &=& + C - A|x + E| + + D \\ \\ + \red{- D} && + \red{- D} \\ \\ + B - D &=& + C - A|x + E| + \end{eqnarray} +

+
+
+

+ Divide both sides by + \red{C - A}. +

+

\qquad + \dfrac{B - D} + {\red{C - A}} = + \dfrac{C - A|x + E|} + {\red{C - A}} +

+
+
+

Simplify:

+

\qquad + SIMPLIFIED = |x + E| +

+
+
+
+

+ Because the absolute value of an expression + is its distance from zero, it has two + solutions, one negative and one positive: +

+

\qquad + -SIMPLIFIED = x + E +

+

or

+

\qquad + SIMPLIFIED = x + E +

+
+
+

+ Solve for the solution where + x + E is negative: +

+

+ \qquad - SIMPLIFIED = x + + E +

+
+
+

+ E > 0 ? "Subtract" : "Add" + \red{abs(E)} + E > 0 ? "from" : "to" both + sides: +

+

\qquad\begin{eqnarray} + - SIMPLIFIED &=& + x + E \\ \\ + \red{- E} && + \red{- E} \\ \\ + -SIMPLIFIED - E + &=& x + \end{eqnarray} +

+
+
+

+ Change the + \red{{} - E} + to an equivalent fraction with a + denominator of + SIMPLIFIED_DENOM. +

+

\qquad + - SIMPLIFIED + \red{E > 0 ? "-" : "+" + fraction(abs(E) * SIMPLIFIED_DENOM, + SIMPLIFIED_DENOM)} = x +

+
+

\qquad + fractionReduce.apply(null, + NEG_SOLUTION) = x +

+
+

+ Then calculate the solution where + x + E is positive: +

+

\qquad + SIMPLIFIED = x + E +

+
+
+

+ E > 0 ? "Subtract" : "Add" + \red{abs(E)} + E > 0 ? "from" : "to" both + sides: +

+

\qquad\begin{eqnarray} + SIMPLIFIED &=& + x + E \\ \\ + \red{- E} && + \red{- E} \\ \\ + SIMPLIFIED - E + &=& x + \end{eqnarray} +

+
+
+

+ Change the + \red{{} - E} + to an equivalent fraction with a + denominator of + SIMPLIFIED_DENOM. +

+

\qquad + SIMPLIFIED + \red{E > 0 ? "-" : "+" + fraction(abs(E) * SIMPLIFIED_DENOM, + SIMPLIFIED_DENOM)} = x +

+
+

\qquad + fractionReduce.apply(null, + POS_SOLUTION) = x +

+
+

+ Thus, the correct answer is + x = + fractionReduce.apply(null, NEG_SOLUTION) + + or + x = + fractionReduce.apply(null, POS_SOLUTION) + . +

+

+ The absolute value cannot be negative. Therefore, there + is no solution. +

-

- Thus, the correct answer is SOLUTION. -

-

- The absolute value cannot be negative. Therefore, there is no solution. -