# Khan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

300 lines (288 sloc) 14.823 kb
 Graphing systems of equations
randRangeNonZero( -5, 5 ) randRange( -5, 5 )
randRangeNonZero( -5, 5 ) randRangeNonZero( -5, 5 )
(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

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 } }); // 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();
Click and drag the points to move the lines.

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 return ( 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 );
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 );
two integers like 6
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 ). Remember that the slope tells you rise over run. So in this case for every abs( SLOPE_1_FRAC[0] ) "position" + ( abs( SLOPE_1_FRAC[0] ) !== 1 ? "s" : "" ) you move down (because it's negative) up you must also move SLOPE_1_FRAC[1] "position" + ( abs( SLOPE_1_FRAC[1] ) !== 1 ? "s" : "" ) to the right.

SLOPE_1_FRAC[1] "position" + ( abs( SLOPE_1_FRAC[1] ) !== 1 ? "s" : "" ) to the right and abs( SLOPE_1_FRAC[0] ) "position" + ( abs( SLOPE_1_FRAC[0] ) !== 1 ? "s" : "" ) 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 ). Remember that the slope tells you rise over run. So in this case for every abs( SLOPE_2_FRAC[0] ) "position" + ( abs( SLOPE_2_FRAC[0] ) !== 1 ? "s" : "" ) you move down (because it's negative) up you must also move SLOPE_2_FRAC[1] "position" + ( abs( SLOPE_1_FRAC[1] ) !== 1 ? "s" : "" ) to the right.

SLOPE_2_FRAC[1] "position" + ( abs( SLOPE_2_FRAC[1] ) !== 1 ? "s" : "" ) to the right and abs( SLOPE_2_FRAC[0] ) "position" + ( abs( SLOPE_2_FRAC[0] ) !== 1 ? "s" : "" ) 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, Y).

style({ stroke: PINK }); circle( [ X, Y ], 0.5 );
Something went wrong with that request. Please try again.