Khan/khan-exercises

Add new problem type to solving_for_the_y-intercept

Test Plan: local mode in chrome

Reviewers: cbhl

Reviewed By: cbhl

CC: alpert

Differential Revision: http://phabricator.khanacademy.org/D2079
1 parent bb18404 commit e0806d7ce3cb471bfa94712066f137606cde637e beneater committed Mar 6, 2013
Showing with 109 additions and 55 deletions.
1. +109 −55 exercises/solving_for_the_y-intercept.html
 @@ -6,87 +6,141 @@
-
- randRangeNonZero(-10, 10) - randRangeNonZero(-10, 10) - randRangeNonZero(-10, 10) - randRangeNonZero(-10, 10) - - abs(X1 - X2)/2 - abs(Y1 - Y2)/2 +
+
+
+ randRangeNonZero(-10, 10) + randRangeNonZero(-10, 10) + randRangeNonZero(-10, 10) + randRangeNonZero(-10, 10) - max(X1, X2) + X_MARGIN - min(X1, X2) - X_MARGIN - max(Y1, Y2) + Y_MARGIN - min(Y1, Y2) - Y_MARGIN + abs(X1 - X2)/2 + abs(Y1 - Y2)/2 - Y1 - Y2 - X1 - X2 + max(X1, X2) + X_MARGIN + min(X1, X2) - X_MARGIN + max(Y1, Y2) + Y_MARGIN + min(Y1, Y2) - Y_MARGIN - SLOPE_NUMERATOR / SLOPE_DENOMINATOR - Y1 - (X1 * M) -
+ Y1 - Y2 + X1 - X2 -
-
+ SLOPE_NUMERATOR / SLOPE_DENOMINATOR + Y1 - (X1 * M) +

The following line passes through point (X1, Y1):

-

y = fractionReduce( SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) x + b

+

y = fractionReduce(SLOPE_NUMERATOR, SLOPE_DENOMINATOR) x + b

What is the value of the y-intercept b?

-

b = (Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR) / SLOPE_DENOMINATOR

+
+

Substituting (X1, Y1) into the equation gives:

+

Y1 = fractionReduce(SLOPE_NUMERATOR, SLOPE_DENOMINATOR) \cdot X1 + b

+

Y1 = fractionReduce(X1 * SLOPE_NUMERATOR , SLOPE_DENOMINATOR) + b

+

b = Y1 - fractionReduce(X1 * SLOPE_NUMERATOR , SLOPE_DENOMINATOR)

+

b = fractionReduce(Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR, SLOPE_DENOMINATOR)

+ +
+

Plugging in fractionReduce(Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR, SLOPE_DENOMINATOR) for b, we get y = fractionReduce(SLOPE_NUMERATOR, SLOPE_DENOMINATOR) x + fractionReduce(Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR, SLOPE_DENOMINATOR).

+
+ graphInit({ + range: max(abs(B) + 4, 11), + scale: 20, + tickStep: 1, + labelStep: 1, + unityLabels: false, + labelFormat: function(s) { return "\\small{" + s + "}"; }, + axisArrows: "<-&rt;" + }); + + plot(function(x) { + return M * x + B; + }, [min((-abs(B) -5), -12) , max((abs(B) + 5), 12)], { + stroke: "#28ae7b" + }); + + circle([X1, Y1], 4 / 20, { + stroke: "none", + fill: "black" + }); + label([X1, Y1], "(" + X1 + ", " + Y1 + ")", p1Position(X1, Y1, X2, Y2)); +
+
+
-
-
-

Substituting (X1, Y1) into the equation gives:

-

Y1 = fractionReduce( SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) \cdot X1 + b

-

Y1 = fractionReduce( X1*SLOPE_NUMERATOR , SLOPE_DENOMINATOR ) + b

-

b = Y1 - fractionReduce( X1*SLOPE_NUMERATOR , SLOPE_DENOMINATOR )

-

b = fractionReduce( Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR, SLOPE_DENOMINATOR )

+
+
+ randRangeNonZero(-10, 10) + randRangeNonZero(-10, 10) + randRangeNonZero(-10, 10) + Y_COEFF * Y_INTERCEPT +
+
+

Given the line:

+

expr(["*", X_COEFF, "x"]) + expr(["*", Y_COEFF, "y"]) = EQUALS

+
+

What is the y-intercept?

+
+ \large(0,\ Y_INTERCEPT\large) +
+
+

The y-intercept is the point where the line crosses the y-axis. This happens when x is zero.

+
+

Set x to zero and solve for y:

+

+ X_COEFF(0) + expr(["*", Y_COEFF, "y"]) = EQUALS +

+
+

expr(["*", Y_COEFF, "y"]) = EQUALS

+
+

\dfrac{Y_COEFFy}{Y_COEFF} = \dfrac{EQUALS}{Y_COEFF}

+

y = Y_INTERCEPT

+
+
+

The line intersects the y-axis at (0, Y_INTERCEPT).

+
+ graphInit({ + range: 11, + scale: 20, + tickStep: 1, + labelStep: 1, + unityLabels: false, + labelFormat: function(s) { return "\\small{" + s + "}"; }, + axisArrows: "<->" + }); -
-

Plugging in fractionReduce( Y1 * SLOPE_DENOMINATOR - X1 * SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) for b, we get y = fractionReduce( SLOPE_NUMERATOR, SLOPE_DENOMINATOR ) x + fractionReduce(Y1*SLOPE_DENOMINATOR-X1*SLOPE_NUMERATOR,SLOPE_DENOMINATOR).

-
- graphInit({ - range: max( abs(B) + 4 , 11 ), - scale: 20, - tickStep: 1, - labelStep: 1, - unityLabels: false, - labelFormat: function( s ) { return "\\small{" + s + "}"; }, - axisArrows: "<->" - }); + style({ stroke: BLUE }); + plot(function(x) { + return (-1 * X_COEFF / Y_COEFF) * x + EQUALS / Y_COEFF; + }, [-11, 11]); - plot(function( x ) { - return M * x + B; - }, [min( ( -abs(B) -5 ), -12) , max( ( abs(B)+5 ), 12 )], { - stroke: "#28ae7b" - }); + circle([0, Y_INTERCEPT], 4 / 20, { + stroke: BLUE, + fill: BLUE + }); - circle( [X1, Y1], 3/20, { - stroke: "none", - fill: "black" - } ); - label( [X1, Y1], "(" + X1 + ", " + Y1 + ")", p1Position( X1, Y1, X2, Y2 ) ); + label([0, Y_INTERCEPT], "(0, " + Y_INTERCEPT + ")", "right", { labelDistance: 5 }); +
+