# Khan/khan-exercises

jeffdyer committed Jan 18, 2012
1 parent b5c2b40 commit 906de7f54148444c4d7a17f2898fb2b7fe719d13
Showing with 70 additions and 19 deletions.
1. +58 −0 exercises/polynomial_intuition_0.html
2. +1 −1 utils/ast.js
3. +11 −18 utils/math-model.js
 @@ -0,0 +1,58 @@ + + + + + Polynomial Intuition + + + +
+
+
+
+ MathModel.init() + randRange(0, 4) + randRangeNonZero(-1, 1) + MATH.parse(SIGN+"*x^"+DEGREE) +
+
+

+ What is the degree of the polynomial function graphed below? +

+
+ MATH.graph(P, BLUE, 17) +
+
+
+ DEGREE +
+
+

+ The degree of a polynomial determines the rate at which its value increases as a function + of its variable. +

+
+

+ One way to determine the degree of polynomial function is by experimenting with different values + for its variable. In the graph above, we see that: +

+

+ f(-2)=MATH.eval(P, {x:-2})
+ f(-1)=MATH.eval(P, {x:-1})
+ f(0)=MATH.eval(P, {x:0})
+ f(1)=MATH.eval(P, {x:1})
+ f(2)=MATH.eval(P, {x:2})
+

+
+

+ The value of the function is changing at a rate of MATH.format("x^"+DEGREE). +

+

+ Therefore we know that the polynomial function is of degree MATH.format(DEGREE). +

+
+
+
+
+ +
 @@ -19,7 +19,7 @@ jQuery.extend ( KhanUtil, { - ASSERT: true, + ASSERT: false, assert: function (val, str) { if ( !this.ASSERT ) {
 @@ -82,19 +82,7 @@ jQuery.extend ( KhanUtil, { // private implementation - function graphInit() { - var graph = KhanUtil.currentGraph; - - graph.graphInit({ - range: 11, - scale: 20, - axisArrows: "<->", - tickStep: 1, - labelStep: 1 - }); - } - - function graph(n, color) { + function graph(n, color, range) { var graph = KhanUtil.currentGraph; function g(x) { @@ -104,6 +92,11 @@ jQuery.extend ( KhanUtil, { return val; } + if (!range) { + range = 10; + } + + if (graph.last) { jQuery(graph).remove(); graph.last.remove(); @@ -112,15 +105,15 @@ jQuery.extend ( KhanUtil, { stroke: color, strokeWidth: 3, fill: "none", - clipRect:[ [-10, -10], [20, 20] ], + clipRect:[ [-range, -range], [2*range, 2*range] ], arrows: null }); graph.last = graph.plot( g, [-10, 10] ); } else { graph.graphInit({ - range: 11, + range: range+1, scale: 20, axisArrows: "<->", tickStep: 1, @@ -130,12 +123,12 @@ jQuery.extend ( KhanUtil, { stroke: color, strokeWidth: 3, fill: "none", - clipRect:[ [-10, -10], [20, 20] ], + clipRect:[ [-range, -range], [2*range, 2*range] ], arrows: null }); - graph.plot( g, [-10, 10] ); - graph.last = graph.plot( g, [-10, 10] ); + graph.plot( g, [-range, range] ); + graph.last = graph.plot( g, [-range, range] ); } }