Permalink
Browse files

add exercise on polynomial intuition

  • Loading branch information...
1 parent 0415132 commit 767d7c442d39c628b630c4d92e9f3f5244af5d15 @jeffdyer jeffdyer committed Jan 17, 2012
Showing with 256 additions and 126 deletions.
  1. +76 −0 exercises/polynomial_intuition_1.html
  2. +1 −2 utils/ast.js
  3. +179 −124 utils/math-model.js
@@ -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>
View
@@ -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");
@@ -20,7 +19,7 @@
jQuery.extend ( KhanUtil, {
- ASSERT: false,
+ ASSERT: true,
assert: function (val, str) {
if ( !this.ASSERT ) {
Oops, something went wrong.

0 comments on commit 767d7c4

Please sign in to comment.