# Khan/khan-exercises

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
397 lines (381 sloc) 20.8 KB
 Graphing systems of equations
randRangeNonZero( -5, 5 ) randRange( -5, 5 )
randRangeExclude(-5, 5, [0, Y]) randRangeExclude(-5, 5, [0, Y])
(Y - YINT_1) / X (Y - YINT_2) / X toFraction( SLOPE_1, 0.001 ) toFraction( SLOPE_2, 0.001 )
SLOPE_1 === 1 ? "" : ( SLOPE_1 === -1 ? "-" : decimalFraction( SLOPE_1, true, true ) ) SLOPE_2 === 1 ? "" : ( SLOPE_2 === -1 ? "-" : decimalFraction( SLOPE_2, true, true ) ) randRangeNonZero( -2, 2 ) randRangeNonZero( -2, 2 ) ( Y - YINT_1 ) * -MULT_1 ( Y - YINT_2 ) * -MULT_2 X * MULT_1 X * MULT_2 X * YINT_1 * MULT_1 X * YINT_2 * MULT_2 true true

Graph this system of equations and solve.

expr([ "+", [ "*", A1, "x" ], [ "*", B1, "y" ] ]) = C1

y = PRETTY_SLOPE_1 x + YINT_1

expr([ "+", [ "*", A2, "x" ], [ "*", B2, "y" ] ]) = C2

y = PRETTY_SLOPE_2 x + YINT_2

Drag the points to plot the system.

graphInit({ range: 11, scale: 20, axisArrows: "<->", tickStep: 1, labelStep: 1 }); addMouseLayer(); graph.pointA = addMovablePoint({ coord: [ -5, 5 ], snapX: 0.5, snapY: 0.5, normalStyle: { stroke: KhanUtil.BLUE, fill: KhanUtil.BLUE } }); graph.pointB = addMovablePoint({ coord: [ 5, 5 ], snapX: 0.5, snapY: 0.5, normalStyle: { stroke: KhanUtil.BLUE, fill: KhanUtil.BLUE } }); graph.pointC = addMovablePoint({ coord: [ -5, -5 ], snapX: 0.5, snapY: 0.5, normalStyle: { stroke: KhanUtil.GREEN, fill: KhanUtil.GREEN } }); graph.pointD = addMovablePoint({ coord: [ 5, -5 ], snapX: 0.5, snapY: 0.5, normalStyle: { stroke: KhanUtil.GREEN, fill: KhanUtil.GREEN } }); graph.line1 = addMovableLineSegment({ pointA: graph.pointA, pointZ: graph.pointB, fixed: true, extendLine: true }); graph.line2 = addMovableLineSegment({ pointA: graph.pointC, pointZ: graph.pointD, fixed: true, extendLine: true, normalStyle: { "stroke": KhanUtil.GREEN, "stroke-width": 2 } }); graph.showCorrect1 = function() { graph.pointA.moveTo( 0, YINT_1, true ); graph.pointB.moveTo( SLOPE_1_FRAC[1], YINT_1 + SLOPE_1_FRAC[0], true ); }; graph.showCorrect2 = function() { graph.pointC.moveTo( 0, YINT_2, true ); graph.pointD.moveTo( SLOPE_2_FRAC[1], YINT_2 + SLOPE_2_FRAC[0], true ); }; // A and B can't be in the same place graph.pointA.onMove = function( x, y ) { return ( x != graph.pointB.coord[0] || y != graph.pointB.coord[1] ); } graph.pointB.onMove = function( x, y ) { return ( x != graph.pointA.coord[0] || y != graph.pointA.coord[1] ); } // C and D can't be in the same place graph.pointC.onMove = function( x, y ) { return ( x != graph.pointD.coord[0] || y != graph.pointD.coord[1] ); } graph.pointD.onMove = function( x, y ) { return ( x != graph.pointC.coord[0] || y != graph.pointC.coord[1] ); } graph.pointC.toFront(); graph.pointD.toFront(); graph.pointA.toFront(); graph.pointB.toFront();

x = X

y = Y

[ graph.pointA.coord, graph.pointB.coord, graph.pointC.coord, graph.pointD.coord ]
var slope1 = ( guess[1][1] - guess[0][1] ) / ( guess[1][0] - guess[0][0] ); var slope2 = ( guess[3][1] - guess[2][1] ) / ( guess[3][0] - guess[2][0] ); var yint1 = slope1 * ( 0 - guess[0][0] ) + guess[0][1]; var yint2 = slope2 * ( 0 - guess[2][0] ) + guess[2][1]; // allows blue function to be graphed with green line and vice versa, fwiw var graphCorrect = ( abs( SLOPE_1 - slope1 ) < 0.001 && abs( SLOPE_2 - slope2 ) < 0.001 && abs( YINT_1 - yint1 ) < 0.001 && abs( YINT_2 - yint2 ) < 0.001 ) || ( abs( SLOPE_1 - slope2 ) < 0.001 && abs( SLOPE_2 - slope1 ) < 0.001 && abs( YINT_2 - yint1 ) < 0.001 && abs( YINT_1 - yint2 ) < 0.001 ); var pointCorrect = parseInt(\$("#solutionarea input").eq(0).val()) === X && parseInt(\$("#solutionarea input").eq(1).val()) === Y; if (pointCorrect && !graphCorrect) { return "You found the right solution to the system of equations, but you haven't graphed them correctly."; } return graphCorrect;
graph.pointA.setCoord( guess[0] ); graph.pointB.setCoord( guess[1] ); graph.pointC.setCoord( guess[2] ); graph.pointD.setCoord( guess[3] ); graph.line1.transform( true ); graph.line2.transform( true );
false false
random() < 0.5 ? true : false !STD_FORM_1

Convert the first equation, expr([ "+", [ "*", A1, "x" ], [ "*", B1, "y" ] ]) = C1, to slope-intercept form.

y = PRETTY_SLOPE_1 x + YINT_1

The y-intercept for the first equation is YINT_1, so the first line must pass through the point (0, YINT_1).

The slope for the first equation is decimalFraction(SLOPE_1, true, true). So for every abs(SLOPE_1_FRAC[0]) positions you move down (because it's negative)up, you must also move SLOPE_1_FRAC[1] positions to the right. So for every abs(SLOPE_1_FRAC[0]) positions you move down (because it's negative)up, you must also move SLOPE_1_FRAC[1] position to the right. So for every abs(SLOPE_1_FRAC[0]) position you move down (because it's negative)up, you must also move SLOPE_1_FRAC[1] positions to the right. So for every abs(SLOPE_1_FRAC[0]) position you move down (because it's negative)up, you must also move SLOPE_1_FRAC[1] position to the right.

SLOPE_1_FRAC[1] positions to the right and abs(SLOPE_1_FRAC[0]) positions downup from (0, YINT_1) is (SLOPE_1_FRAC[1], YINT_1 + SLOPE_1_FRAC[0]). SLOPE_1_FRAC[1] positions to the right and abs(SLOPE_1_FRAC[0]) position downup from (0, YINT_1) is (SLOPE_1_FRAC[1], YINT_1 + SLOPE_1_FRAC[0]). SLOPE_1_FRAC[1] position to the right and abs(SLOPE_1_FRAC[0]) positions downup from (0, YINT_1) is (SLOPE_1_FRAC[1], YINT_1 + SLOPE_1_FRAC[0]). SLOPE_1_FRAC[1] position to the right and abs(SLOPE_1_FRAC[0]) position downup from (0, YINT_1) is (SLOPE_1_FRAC[1], YINT_1 + SLOPE_1_FRAC[0]).

Graph the blue line so it passes through (0, YINT_1) and (SLOPE_1_FRAC[1], YINT_1 + SLOPE_1_FRAC[0]).

Convert the second equation, expr([ "+", [ "*", A2, "x" ], [ "*", B2, "y" ] ]) = C2, to slope-intercept form.

y = PRETTY_SLOPE_2 x + YINT_2

The y-intercept for the second equation is YINT_2, so the second line must pass through the point (0, YINT_2).

The slope for the second equation is decimalFraction(SLOPE_2, true, true). So for every abs(SLOPE_2_FRAC[0]) positions you move down (because it's negative)up, you must also move SLOPE_2_FRAC[1] positions to the right. So for every abs(SLOPE_2_FRAC[0]) positions you move down (because it's negative)up, you must also move SLOPE_2_FRAC[1] position to the right. So for every abs(SLOPE_2_FRAC[0]) position you move down (because it's negative)up, you must also move SLOPE_2_FRAC[1] positions to the right. So for every abs(SLOPE_2_FRAC[0]) position you move down (because it's negative)up, you must also move SLOPE_2_FRAC[1] position to the right.

SLOPE_2_FRAC[1] positions to the right and abs(SLOPE_2_FRAC[0]) positions downup from (0, YINT_2) is (SLOPE_2_FRAC[1], YINT_2 + SLOPE_2_FRAC[0]). SLOPE_2_FRAC[1] positions to the right and abs(SLOPE_2_FRAC[0]) position downup from (0, YINT_2) is (SLOPE_2_FRAC[1], YINT_2 + SLOPE_2_FRAC[0]). SLOPE_2_FRAC[1] position to the right and abs(SLOPE_2_FRAC[0]) positions downup from (0, YINT_2) is (SLOPE_2_FRAC[1], YINT_2 + SLOPE_2_FRAC[0]). SLOPE_2_FRAC[1] position to the right and abs(SLOPE_2_FRAC[0]) position downup from (0, YINT_2) is (SLOPE_2_FRAC[1], YINT_2 + SLOPE_2_FRAC[0]).

Graph the green line so it passes through (0, YINT_2) and (SLOPE_2_FRAC[1], YINT_2 + SLOPE_2_FRAC[0]).

The solution is the point where the two lines intersect.

The lines intersect at x = X, y = Y.

style({ stroke: PINK }); circle( [ X, Y ], 0.5 );