This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 863
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use regex answer type to avoid dependency on math-model
Summary: I changed this to use regexs to check the answer and made it pretty liberal (i.e. it's always ok to run a -1 through everything) Differential Revision: http://phabricator.khanacademy.org/D566
- Loading branch information
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!DOCTYPE html> | ||
<html data-require="math math-format word-problems expressions"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<title>Factoring linear binomials</title> | ||
<script src="../khan-exercise.js"></script> | ||
</head> | ||
<body> | ||
<div class="exercise"> | ||
<div class="problems"> | ||
<div> | ||
<div class="vars"> | ||
<var id="A">randRange(2, 9)</var> | ||
<var id="IS_IRREDUCIBLE">random() < 0.2</var> | ||
|
||
<div data-ensure="(GCD === 1) === IS_IRREDUCIBLE"> | ||
<var id="B">randRangeExclude(-20, 20, [-1, 0, 1])</var> | ||
<var id="GCD">getGCD(A, B)</var> | ||
</div> | ||
<var id="SOLUTION"> | ||
IS_IRREDUCIBLE ? plus(A + "x", B) : | ||
GCD + "(" + plus(A / GCD + "x", B / GCD) + ")" | ||
</var> | ||
<var id="Ax_FACTORS"> | ||
toSentenceTex(getFactors(abs(A)).concat(["x"])) | ||
</var> | ||
<var id="B_FACTORS"> | ||
toSentenceTex(getFactors(abs(B))) | ||
</var> | ||
<var id="TERM1">GCD</var> | ||
<var id="TERM1N">"[-\\u2212]" + GCD</var> | ||
<var id="TERM2">"(?:" + (A < 0 ? "[-\\u2212]" : "") + abs(A / GCD) + (A / GCD === 1 ? "|" : "" ) + (A / GCD === -1 ? "|[-\\u2212]" : "") + ")\\s*x"</var> | ||
<var id="TERM2N">"(?:" + (A > 0 ? "[-\\u2212]" : "") + abs(A / GCD) + (A / GCD === -1 ? "|" : "" ) + (A / GCD === 1 ? "|[-\\u2212]" : "") + ")\\s*x"</var> | ||
<var id="TERM3">(B < 0 ? "[-\\u2212]" : "\\+") + "\\s*" + abs(B / GCD)</var> | ||
<var id="TERM3N">(B > 0 ? "[-\\u2212]" : "\\+") + "\\s*" + abs(B / GCD)</var> | ||
</div> | ||
<p class="question"> | ||
Write the following expression in its most factored form: | ||
</p> | ||
<p class="problem"> | ||
<code><var>expr(["+", ["*", A, "x"], B])</var></code> | ||
</p> | ||
<div class="solution" data-type="set"> | ||
<div data-if="IS_IRREDUCIBLE" data-unwrap> | ||
<div class="set-sol" data-type="regex">^\s*<var>TERM2</var>\s*<var>TERM3</var>\s*$</div> | ||
<div class="set-sol" data-type="regex">^\s*<var>TERM2N</var>\s*<var>TERM3N</var>\s*$</div> | ||
<div class="set-sol" data-type="regex">^\s*\(\s*<var>TERM2</var>\s*<var>TERM3</var>\s*\)\s*$</div> | ||
<div class="set-sol" data-type="regex">^\s*\(\s*<var>TERM2N</var>\s*<var>TERM3N</var>\s*\)\s*$</div> | ||
</div> | ||
<div data-else data-unwrap> | ||
<div class="set-sol" data-type="regex">^\s*<var>TERM1</var>\s*\(\s*<var>TERM2</var>\s*<var>TERM3</var>\s*\)\s*$</div> | ||
<div class="set-sol" data-type="regex">^\s*<var>TERM1N</var>\s*\(\s*<var>TERM2N</var>\s*<var>TERM3N</var>\s*\)\s*$</div> | ||
</div> | ||
<div class="input-format"><span class="entry"></span></div> | ||
<div class="example"> | ||
a factored expression, like <b>5(x+2)</b> | ||
</div> | ||
</div> | ||
<div class="hints"> | ||
<p> | ||
To factor a polynomial, you should first try to find | ||
the greatest common factor of all the terms. | ||
</p> | ||
<p> | ||
The factors of <code><var>A</var>x</code> are | ||
<var>Ax_FACTORS</var> and the factors of | ||
<code><var>B</var></code> are <var>B_FACTORS</var>. | ||
</p> | ||
<p> | ||
The greatest common factor of <code><var>A</var>x</code> | ||
and <code><var>B</var></code> is | ||
<code><var>GCD</var></code>. | ||
</p> | ||
|
||
<p data-if="IS_IRREDUCIBLE"> | ||
Since the greatest common factor is <code>1</code>, | ||
the expression is already in its most factored form. | ||
</p> | ||
<p data-if="IS_IRREDUCIBLE" class="final_answer"> | ||
Therefore the answer is the original expression, | ||
<code><var>SOLUTION</var></code>. | ||
</p> | ||
|
||
<p data-if="!IS_IRREDUCIBLE"> | ||
We can factor out the <code><var>GCD</var></code> and | ||
put it before the parenthesis. | ||
</p> | ||
<p data-if="!IS_IRREDUCIBLE"> | ||
If we divide each of the terms in the original | ||
expression by <code><var>GCD</var></code> we get | ||
<code>\dfrac{<var>A</var>x}{<var>GCD</var>} = | ||
<var>plus((A/GCD) + "x")</var></code> and | ||
<code>\dfrac{<var>B</var>}{<var>GCD</var>} = | ||
<var>B/GCD</var></code>. | ||
</p> | ||
<p data-if="!IS_IRREDUCIBLE" class="final_answer"> | ||
So the factored expression is | ||
<code><var>SOLUTION</var></code>. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |