Khan/khan-exercises

Subversion checkout URL

You can clone with
or
.
Older
100644 329 lines (315 sloc) 18.58 kB
 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 13, 2011 1 2 3 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 4 5 Graphing inequalities 2 6 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 7 8 9 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 10
11
12
13 reduce( randRangeNonZero( -5, 5 ), randRange( 1, 5 ) ) 14 randRangeNonZero( max( -10, -10 - SLOPE_FRAC[0] ), min( 10, 10 - SLOPE_FRAC[0] ) ) 15 SLOPE_FRAC[0] / SLOPE_FRAC[1] 16 SLOPE === 1 ? "" : ( SLOPE === -1 ? "-" : fraction( SLOPE_FRAC[0], SLOPE_FRAC[1], true, true ) ) 17 randRangeNonZero( -3, 3 ) 18 SLOPE_FRAC[0] * -MULT 19 SLOPE_FRAC[1] * MULT 20 SLOPE_FRAC[1] * YINT * MULT 21 randFromArray([ true, false ]) 22 randFromArray([ "<", ">", "≤", "≥" ]) 23 B < 0 ? { "<": ">", ">": "<", "≤": "≥", "≥": "≤" }[ COMP ] : COMP 24 COMP === "<" || COMP === "≤" 25 COMP === "≥" || COMP === "≤" 26
27 [ randRangeExclude( -9, 9, [ -3, -2, -1, 0 ] ), randRangeExclude( -9, 9, [ -1, -2 ] ) ] 28 [ randRangeExclude( -9, 9, [ -3, -2, -1, 0 ] ), randRangeExclude( -9, 9, [ -1, -2 ] ) ] 29 30 (((COMP === "<") && ( POINT_1[1] < SLOPE * POINT_1[0] + YINT )) 31 || ((COMP === "≤") && ( POINT_1[1] <= SLOPE * POINT_1[0] + YINT )) 32 || ((COMP === ">") && ( POINT_1[1] > SLOPE * POINT_1[0] + YINT )) 33 || ((COMP === "≥") && ( POINT_1[1] >= SLOPE * POINT_1[0] + YINT ))) 34 35 36 (((COMP === "<") && ( POINT_2[1] < SLOPE * POINT_2[0] + YINT )) 37 || ((COMP === "≤") && ( POINT_2[1] <= SLOPE * POINT_2[0] + YINT )) 38 || ((COMP === ">") && ( POINT_2[1] > SLOPE * POINT_2[0] + YINT )) 39 || ((COMP === "≥") && ( POINT_2[1] >= SLOPE * POINT_2[0] + YINT ))) 40 41
42
10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 43 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 44 45 Graph the following inequality and determine if the points 46 (POINT_1[0], POINT_1[1]) or 47 (POINT_2[0], POINT_2[1]) are solutions: 48 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 49 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 50
51

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

54

55 y COMP PRETTY_SLOPE x + YINT 56

10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 57 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 58 59 63 70 77 78 79 graphInit({ 80 range: 11, 81 scale: 20, 82 axisArrows: "<->", 83 tickStep: 1, 84 labelStep: 1, 85 gridOpacity: 0.05, 86 axisOpacity: 0.2, 87 tickOpacity: 0.4, 88 labelOpacity: 0.5 89 }); 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 90 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 91 label( [ 0, -11 ], "y", "below" ); 92 label( [ 11, 0 ], "x", "right" ); 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 93 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 94 addMouseLayer(); 95 graph.pointA = addMovablePoint({ 96 coord: [ -5, 5 ], 97 snapX: 0.5, 98 snapY: 0.5, 99 normalStyle: { 100 stroke: KhanUtil.BLUE, 101 fill: KhanUtil.BLUE 102 } 103 }); 104 graph.pointB = addMovablePoint({ 105 coord: [ 5, 5 ], 106 snapX: 0.5, 107 snapY: 0.5, 108 normalStyle: { 109 stroke: KhanUtil.BLUE, 110 fill: KhanUtil.BLUE 111 } 112 }); 113 graph.line1 = bogusShape; 114 graph.shading = bogusShape; 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 115 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 116 graph.update = function() { 117 graph.line1.remove(); 118 graph.shading.remove(); 119 if ( abs( graph.pointB.coord[0] - graph.pointA.coord[0] ) > 0.001 ) { 120 var slope = ( graph.pointB.coord[1] - graph.pointA.coord[1] ) / ( graph.pointB.coord[0] - graph.pointA.coord[0] ); 121 var yint = slope * ( 0 - graph.pointA.coord[0] ) + graph.pointA.coord[1]; 122 var shadeEdge = ( ( graph.pointA.coord[0] < graph.pointB.coord[0] ) ? graph.shadetop : !graph.shadetop ) ? 11 : -11; 123 style({ stroke: BLUE, strokeWidth: 2, strokeDasharray: graph.dasharray }, function() { 124 graph.line1 = line( [ -11, -11 * slope + yint ], [ 11, 11 * slope + yint ] ).toBack(); 125 }); 126 style({ fill: BLUE, stroke: null, opacity: KhanUtil.FILL_OPACITY }, function() { 127 graph.shading = path([ [ 11, shadeEdge ], [ 11, 11 * slope + yint ], [ -11, -11 * slope + yint ], [ -11, shadeEdge ] ]); 128 }); 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 129 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 130 } else { 131 // vertical line 132 var x = graph.pointA.coord[0]; 133 var shadeEdge = ( ( graph.pointB.coord[1] < graph.pointA.coord[1] ) ? graph.shadetop : !graph.shadetop ) ? 11 : -11; 134 style({ stroke: BLUE, strokeWidth: 2, strokeDasharray: graph.dasharray }, function() { 135 graph.line1 = line( [ x, -11 ], [ x, 11 ] ).toBack(); 136 }); 137 style({ fill: BLUE, stroke: null, opacity: KhanUtil.FILL_OPACITY }, function() { 138 graph.shading = path([ [ x, -11 ], [ x, 11 ], [ shadeEdge, 11 ], [ shadeEdge, -11 ] ]); 139 }); 140 } 141 }; 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 142 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 143 // A and B can't be in the same place 144 graph.pointA.onMove = function( x, y ) { 145 if ( x != graph.pointB.coord[0] || y != graph.pointB.coord[1] ) { 146 graph.pointA.setCoord([ x, y ]); 147 graph.update(); 148 return true; 149 } else { 150 return false; 151 } 152 } 153 graph.pointB.onMove = function( x, y ) { 154 if ( x != graph.pointA.coord[0] || y != graph.pointA.coord[1] ) { 155 graph.pointB.setCoord([ x, y, ]); 156 graph.update(); 157 return true; 158 } else { 159 return false; 160 } 161 } 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 162 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 163 graph.dasharray = ""; 164 graph.shadetop = true; 165 graph.update(); 166 graph.pointA.toFront(); 167 graph.pointB.toFront(); 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 168 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 169
10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 170 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 171 172 173 174 175 Drag the two points to move the line into the correct position. 176 177 [ graph.pointA.coord, graph.pointB.coord, 178 graph.pointA.coord[0] > graph.pointB.coord[0] ? graph.shadetop : !graph.shadetop, 179 graph.dasharray === "- " ? false : true ] 180 181 182 var slope = ( guess[1][1] - guess[0][1] ) / ( guess[1][0] - guess[0][0] ); 183 var yint = slope * ( 0 - guess[0][0] ) + guess[0][1]; 184 return abs( SLOPE - slope ) < 0.001 185 && abs( YINT - yint ) < 0.001 186 && guess[2] === LESS_THAN 187 && guess[3] === INCLUSIVE; 188 189 190 graph.pointA.setCoord( guess[0] ); 191 graph.pointB.setCoord( guess[1] ); 192 graph.shadetop = graph.pointA.coord[0] > graph.pointB.coord[0] ? guess[2] : !guess[2]; 193 if ( guess[3] ) { 194 graph.dasharray = ""; 195$( "input[name=dashradio][value=solid]" ).attr( "checked", true ); 196 } else { 197 graph.dasharray = "- "; 198 $( "input[name=dashradio][value=dashed]" ).attr( "checked", true ); 199 } 200 graph.update(); 201 202 203 204 205 206 207 208 209 graph the inequality 210 make sure the correct side is shaded 211 make sure the line is correctly shown as solid or dashed 212 213 214 10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 215 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 216
217
218

219 Convert expr([ "+", [ "*", A, "x" ], [ "*", B, "y" ] ]) STD_FORM_COMP C 220 to slope-intercept form by solving for y. 221

222
223

224 A < 0 ? "Add" : "Subtract" abs( A )x A < 0 ? "to" : "from" both sides: 225

226 \qquad expr( [ "*", B, "y" ] ) STD_FORM_COMP expr([ "+", [ "*", -A, "x" ], C ]) 227

228
229
230

231 Divide both sides by B. Since you're multiplying or dividing by a negative number, don't forget to flip the inequality sign: 232

233 \qquad y COMP expr([ "+", "\\dfrac{" + expr([ "*", -A, "x" ]) + "}{" + B + "}", "\\dfrac{" + C + "}{" + B + "}" ]) 234

235
236
237
238

239 \qquad y COMP \color{purple}{PRETTY_SLOPE} x \color{GREEN}{+ YINT} 240

241 The y-intercept is YINT and the slope is decimalFraction( SLOPE, true, true ). 242 Since the y-intercept is YINT, the line must pass through the point (0, YINT). 243

244
245 style({ stroke: GREEN, fill: GREEN }, function() { 246 graph.yint = circle( [ 0, YINT ], 0.2 ).toBack(); 247 }); 248
249
250
251

252 The slope is decimalFraction( SLOPE, true, true ). Remember that 253 the slope tells you rise over run. So in this case for every 254 abs( SLOPE_FRAC[0] ) 255 "position" + ( abs( SLOPE_FRAC[0] ) !== 1 ? "s" : "" ) 256 you move 257 down (because it's negative) 258 up 259 you must also move 260 SLOPE_FRAC[1] 261 "position" + ( abs( SLOPE_FRAC[1] ) !== 1 ? "s" : "" ) 262 to the right. So the line must also pass through (SLOPE_FRAC[1], YINT + SLOPE_FRAC[0]) 263

264
265 style({ 266 stroke: "purple", 267 strokeWidth: 2, 268 arrows: "->" 269 }, function() { 270 path([ [ 0, YINT ], [ 0, YINT + SLOPE_FRAC[0] ] ]).toBack(); 271 path([ [ 0, YINT + SLOPE_FRAC[0] ], [ SLOPE_FRAC[1], YINT + SLOPE_FRAC[0] ] ]).toBack(); 272 }); 273 label( [ 0, YINT + SLOPE_FRAC[0] / 2 ], abs( SLOPE_FRAC[0] ) + " \\text{ " + ( SLOPE_FRAC[0] < 0 ? "down" : "up" ) + "} \\quad", "left", { color: "purple" } ); 274 label( [ 0, YINT + SLOPE_FRAC[0] ], SLOPE_FRAC[1] + " \\text{ right}", ( SLOPE_FRAC[0] < 0 ? "below right" : "above right" ), { color: "purple" } ); 275 graph.yint.toBack(); 276
277
278

279 Since our inequality has a LESS_THAN ? "less-than" : "greater-than"INCLUSIVE ? " or equal to" : "" sign, that means that any point 280 LESS_THAN ? "below" : "above" the line is a solution to the inequality, so the area LESS_THAN ? "below" : "above" 281 the line should be shaded. 282

283
284

285 Note that since the sign is LESS_THAN ? "less-than" : "greater-than" or equal to, any point on the line is also a solution, so the 286 line should be solid. 287

288

289 Note that since the sign is LESS_THAN ? "less-than" : "greater-than" (and not equal to), any point on the line is not part of the solution, 290 so the line should be dashed to indicate this. 291

292
293
294

295 Plot each of the points to determine which are solutions: 296 (POINT_1[0], POINT_1[1]) and 297 (POINT_2[0], POINT_2[1]) 298

299
300 style({ stroke: PINK, fill: PINK }, function() { 301 circle( [ POINT_1[0], POINT_1[1] ], 0.2 ).toBack(); 302 circle( [ POINT_2[0], POINT_2[1] ], 0.2 ).toBack(); 303 }); 304
305
306
307

308 (POINT_1[0], POINT_1[1]) is a solution because it's inside the shaded area, but 309 (POINT_2[0], POINT_2[1]) is not. 310

311

312 (POINT_1[0], POINT_1[1]) is outside the shaded area, so it's not a solution, but 313 (POINT_2[0], POINT_2[1]) is a solution. 314

315

Both 316 (POINT_1[0], POINT_1[1]) and 317 (POINT_2[0], POINT_2[1]) are solutions because they're inside the shaded area. 318

319

Neither 320 (POINT_1[0], POINT_1[1]) nor 321 (POINT_2[0], POINT_2[1]) are solutions because they are not within the shaded area. 322

323
324
10b1798 Add exercise: Graphing inequalities 2 beneater authored Nov 14, 2011 325 326
327 328
Something went wrong with that request. Please try again.