Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
347 lines (328 sloc) 17.8 KB
 Graphing and solving linear inequalities
reduce(randRangeNonZero(-5, 5), randRange(1, 5)) randRangeNonZero( max( -10, -10 - SLOPE_FRAC[0] ), min( 10, 10 - SLOPE_FRAC[0] ) ) SLOPE_FRAC[0] / SLOPE_FRAC[1] fractionVariable(SLOPE_FRAC[0], SLOPE_FRAC[1], "x") randRangeNonZero( -3, 3 ) SLOPE_FRAC[0] * -MULT SLOPE_FRAC[1] * MULT SLOPE_FRAC[1] * YINT * MULT randFromArray([ true, false ]) randFromArray([ "<", ">", "≤", "≥" ]) B < 0 ? { "<": ">", ">": "<", "≤": "≥", "≥": "≤" }[ COMP ] : COMP COMP === "<" || COMP === "≤" COMP === "≥" || COMP === "≤" (function() { // Create a point on the line var minN = floor(9 / abs(SLOPE_FRAC[1])); var n = randRange(-minN, minN); return [n * SLOPE_FRAC[1], YINT+ n * SLOPE_FRAC[0]]; })() randFromArray([ [randRangeExclude(-9, 9, [-3, -2, -1, 0]), randRangeExclude(-9, 9, [-1, -2])], [randRangeExclude(-9, 9, [-3, -2, -1, 0]), randRangeExclude(-9, 9, [-1, -2])], EDGE_POINT ]) POINT[1] === SLOPE * POINT[0] + YINT (function() { if (POINT_ON_LINE) { return INCLUSIVE; } return (POINT[1] < SLOPE * POINT[0] + YINT) ? LESS_THAN : !LESS_THAN; })()

Graph the following inequality:

expr([ "+", [ "*", A, "x" ], [ "*", B, "y" ] ]) STD_FORM_COMP C

y COMP PRETTY_SLOPE + YINT

[ graph.pointA.coord, graph.pointB.coord, graph.pointA.coord[0] > graph.pointB.coord[0] ? graph.shadetop : !graph.shadetop, graph.dasharray === "- " ? false : true, $("input[name='isSolution']:checked").attr("id")] if (_.isEqual(guess, [[-5, 5], [5, 5], false, true])) { return ""; } var slope = ( guess[1][1] - guess[0][1] ) / ( guess[1][0] - guess[0][0] ); var yint = slope * ( 0 - guess[0][0] ) + guess[0][1]; return abs( SLOPE - slope ) < 0.001 && abs( YINT - yint ) < 0.001 && guess[2] === LESS_THAN && guess[3] === INCLUSIVE && POINT_SOLUTION === (guess[4] === 'yes'); graph.pointA.setCoord( guess[0] ); graph.pointB.setCoord( guess[1] ); graph.shadetop = graph.pointA.coord[0] > graph.pointB.coord[0] ? guess[2] : !guess[2]; if ( guess[3] ) { graph.dasharray = "";$( "input[name=dashradio][value=solid]" ).attr( "checked", true ); } else { graph.dasharray = "- "; $( "input[name=dashradio][value=dashed]" ).attr( "checked", true ); } graph.update(); Let's first convert the inequality into slope-intercept form, which allows us to determine the y-intercept and the slope of the line in order to graph it. \qquad\begin{eqnarray} expr(["+", ["*", A, "x"], ["*", B, "y"]]) &STD_FORM_COMP& C \\ coefficient(B)y &STD_FORM_COMP& expr([ "+", [ "*", -A, "x" ], C ]) \\ y &COMP& PRETTY_SLOPE + YINT \end{eqnarray} Since the inequality is in slope-intercept form, we can use the y-intercept and the slope of the line in order to graph it. The inequality sign then tells us which side of the line is to be shaded and whether the line is solid or dashed. Finally, we can see whether or not our given point lies in the shaded area to check if it's a solution of the inequality. Based on the inequality, we can see that the y-intercept of the boundary line is the point (0, YINT). We can also see that the slope of the line is fractionReduce(SLOPE_FRAC[0], SLOPE_FRAC[1]). This means that for every \blue{SLOPE_FRAC[1]} plural_form(genericUnit[1], SLOPE_FRAC[1]) we increase along the x-axis, we move \pink{abs(SLOPE_FRAC[0])} plural_form(genericUnit[1], SLOPE_FRAC[0]) down the y-axis to find another point on the boundary line: This means that for every \blue{SLOPE_FRAC[1]} plural_form(genericUnit[1], SLOPE_FRAC[1]) we increase along the x-axis, we move \pink{abs(SLOPE_FRAC[0])} plural_form(genericUnit[1], SLOPE_FRAC[0]) up the y-axis to find another point on the boundary line: (0 + \blue{SLOPE_FRAC[1]}, YINT + \pink{SLOPE_FRAC[0]}) = (SLOPE_FRAC[1], YINT + SLOPE_FRAC[0]) We can now connect these points to graph the line. graph.pointA.setCoord([0, YINT]); graph.pointB.setCoord([SLOPE_FRAC[1], YINT + SLOPE_FRAC[0]]); graph.update(); The inequality is y COMP PRETTY_SLOPE + YINT. This means that for each point (x, y) in the solution set, the y-value is less than or equal PRETTY_SLOPE + YINT. Therefore, the solution set lies below the line and the line should be solid. This means that for each point (x, y) in the solution set, the y-value is strictly less than PRETTY_SLOPE + YINT. Therefore, the solution set lies below the line and the line should be dashed. This means that for each point (x, y) in the solution set, the y-value is greater than or equal PRETTY_SLOPE + YINT. Therefore, the solution set lies above the line and the line should be solid. This means that for each point (x, y) in the solution set, the y-value is strictly greater than PRETTY_SLOPE + YINT. Therefore, the solution set lies above the line and the line should be dashed. graph.shadetop = graph.pointA.coord[0] > graph.pointB.coord[0] ? LESS_THAN : !LESS_THAN; if (INCLUSIVE) { graph.dasharray = '';$('input[name=dashradio][value=solid]').attr('checked', true); } else { graph.dasharray = '- '; \$('input[name=dashradio][value=dashed]').attr('checked', true); } graph.update();