# Khan/khan-exercises

Fetching contributors…
Cannot retrieve contributors at this time
133 lines (124 sloc) 8.5 KB
 Graphs of 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] coefficient(fractionReduce(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 === "≤" abs(YINT + SLOPE_FRAC[0]) < 10 ? [SLOPE_FRAC[1], YINT + SLOPE_FRAC[0]] : [-2 * SLOPE_FRAC[1], YINT - 2 * SLOPE_FRAC[0]] abs(YINT - SLOPE_FRAC[0]) < 10 ? [-SLOPE_FRAC[1], YINT - SLOPE_FRAC[0]] : [2 * SLOPE_FRAC[1], YINT + 2 * SLOPE_FRAC[0]] (YINT < 0 && !LESS_THAN) || (YINT > 0 && LESS_THAN)

What is the inequality represented by this graph?

graphInit({ range: 11, scale: 20, axisArrows: "<->", tickStep: 1, labelStep: 1, gridOpacity: 0.05, axisOpacity: 0.2, tickOpacity: 0.4, labelOpacity: 0.5 }); label( [ 0, -11 ], "y", "below" ); label( [ 11, 0 ], "x", "right" ); var dash = INCLUSIVE ? "" : "- "; style({ stroke: BLUE, strokeWidth: 2, strokeDasharray: dash }, function() { line( [ -11, -11 * SLOPE + YINT ], [ 11, 11 * SLOPE + YINT ] ).toBack(); }); graph.shadeEdge = (LESS_THAN ? 11 < YINT : 11 > YINT) ? 11: -11; style({ fill: BLUE, stroke: null, opacity: KhanUtil.FILL_OPACITY }, function() { graph.shading = path([ [ 11, graph.shadeEdge ], [ 11, 11 * SLOPE + YINT ], [ -11, -11 * SLOPE + YINT ], [ -11, graph.shadeEdge ] ]); });

yCOMP SLOPE \space x + YINT

To find the equation of a linear inequality you should first find the equation of the line that forms the boundary of the solution set. This line is shown on the graph above.

One way to find the equation of this line is to choose two points on the line and find the slope and y-intercept from there. Two points on this line are (X1,Y1) and (X2,Y2).

Substitute both points into the equation for the slope of a line.

m = \dfrac{Y2 - negParens(Y1)}{X2 - negParens(X1)} = fractionReduce( Y2 - Y1, X2 - X1 )

To find b, we can substitute in either of the two points into the equation with solved slope.

Using the first point (X1, Y1), substitute y = Y1 and x = X1:

Y1 = (fractionReduce( Y2 - Y1, X2 - X1 ))(X1) + b

b = Y1 - fractionReduce( X1 * ( Y2 - Y1 ), X2 - X1 ) = fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 )

The equation of the line is y = ( SLOPE === -1 ? "-" : ( SLOPE === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 ))) x + fractionReduce( Y1 * (X2 - X1) - X1 * ( Y2 - Y1 ), X2 - X1 ) (the value of m is SLOPE).

Now that we have the equation for the boundary line, we need to decide which inequality sign to use.

If we pick a point on the line, let's say (X1,Y1), we can see that points below that point are all shaded in. These are the points where x = X1 but y is less than Y1. So we should use a < or sign.

If we pick a point on the line, let's say (X1,Y1), we can see that points above that point are all shaded in. These are the points where x = X1 but y is greater than Y1. So we should use a > or sign.

Another way to see this is to try plugging in a point. The easiest point to plug in is (0,0):

y \; ? \; coefficient(fractionReduce(Y2 - Y1, X2 - X1))x + fractionReduce(Y1 * (X2 - X1) - X1 * (Y2 - Y1), X2 - X1)

0 \; ? \; ( SLOPE === -1 ? "-1 \\times" : ( SLOPE === 1 ? "" : fractionReduce( Y2 - Y1, X2 - X1 ) + "\\times")) 0 + fractionReduce(Y1 * (X2 - X1) - X1 * (Y2 - Y1), X2 - X1)

Since (0, 0) is in the shaded area, this expression must be true. Since (0, 0) is not in the shaded area, this expression must be false. So, the ? must be either < or . So, the ? must be either > or .

The line of the graph is solid, so the points on the boundary are in the set of solutions for this inequality.

The line of the graph is dashed, so the points on the boundary are not in the set of solutions for this inequality.

So, we choose the COMP sign, and the final inequality is y COMP PRETTY_SLOPE + YINT.