Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
add exercise on polynomial intuition
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdyer committed Jan 17, 2012
1 parent 0415132 commit 767d7c4
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 126 deletions.
76 changes: 76 additions & 0 deletions exercises/polynomial_intuition_1.html
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html data-require="math graphie ast math-model">
<head>
<meta charset="UTF-8" />
<title>Polynomial Intuition 1</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<div class="exercise">
<div class="problems">
<div>
<div class="vars">
<var id="MATH">MathModel.init()</var>
<var id="b">randRangeNonZero(-3, 3)</var>
<var id="A">1</var>
<var id="B">2*b</var>
<var id="C">b*b</var>
<var id="P">MATH.polynomial([A, B, C], "x")</var>
<!-- use parse so that the ast matches the parsed user input -->
<var id="S">MATH.parse("x^2+"+B+"x+"+C)</var>
</div>
<div>
<p class="question">
Write the equation of the following graph:
</p>
<div class="graphie" id="poly">
MATH.graph(P)
</div>
</div>
<div class="solution" data-type="custom" data-update="poly">
<div class="instruction">
Enter the factored expression here:<br>
<input name="response" type="text" onblur="window._guess=value"></input>
</div>
<div class="guess">window._guess</div>
<div class="validator-function">
var isCorrect = MATH.isEqual(MATH.parse(guess), S);
MATH.graph(MATH.parse(guess), isCorrect?ORANGE:BLUE);
return isCorrect;
</div>
<div class="show-guess">
</div>
<div class="example">x^2-6x+9</div>
</div>
<!--
<div class="hints">
<p>
Recognize that the expression is of the form
<code><var>MATH.format("a^2+2ab+b^2", "normalsize", KhanUtil.BLUE)</var></code>
, which can be factored as
<code><var>MATH.format("(a+b)^2", "normalsize", KhanUtil.BLUE)</var></code>.
</p>
<p>
First, determine the values of
<code><var>MATH.format("a", "normalsize", KhanUtil.BLUE)</var></code> and
<code><var>MATH.format("b", "normalsize", KhanUtil.BLUE)</var></code>.
</p>
<p>
<code><var>MATH.format("a="+"x", "normalsize", KhanUtil.BLUE)</var></code><br><br>
<code><var>MATH.format("b="+2*b+"/"+2+"="+b, "normalsize", KhanUtil.BLUE)</var></code>
</p>
<p>
Replace
<code><var>MATH.format("a", "normalsize", KhanUtil.BLUE)</var></code> and
<code><var>MATH.format("b", "normalsize", KhanUtil.BLUE)</var></code> in the factored equation to find the answer.
</p>
<p>
<code><var>MATH.format("(x+"+b+")^2", "large", KhanUtil.ORANGE)</var></code>
</p>
</div>
-->
</div>
</div>
</div>
</body>
</html>
3 changes: 1 addition & 2 deletions utils/ast.js
Expand Up @@ -3,7 +3,6 @@
@see http://artcompiler.org/articles/asts-for-khan-exercises.pdf
var nid = ast.fromExpr(["=", ["+", 1, 1], 2]));
var node = ast.node(nid); // returns a node object corresponding to nid
var expr = ast.node("lhs");
var answer = ast.node("rhs");
Expand All @@ -20,7 +19,7 @@
jQuery.extend ( KhanUtil, {


ASSERT: false,
ASSERT: true,

assert: function (val, str) {
if ( !this.ASSERT ) {
Expand Down

0 comments on commit 767d7c4

Please sign in to comment.