# Khan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

Older
100644 243 lines (223 sloc) 9.778 kb
 f70a258 Add exercise: Graphing parabolas 0.5 beneater authored Mar 9, 2012 1 cde9e9f Re-run the exercises through the updated cleaner. jeresig authored Apr 24, 2013 2 3 0f0c630 Clean up the exercise files using the new cleaning utility. (II) cbhl authored Apr 16, 2013 4 113bddd Update the title tags to match real display names spicyj authored Apr 11, 2013 5 Graphing parabolas in standard form ac1415e Use requirejs for module loading spicyj authored Mar 5, 2014 6 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 7 f70a258 Add exercise: Graphing parabolas 0.5 beneater authored Mar 9, 2012 15 16 17 0f0c630 Clean up the exercise files using the new cleaning utility. (II) cbhl authored Apr 16, 2013 18 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 19 1 20 randRange( -4, 4 ) 21 randRange( [ -5, -7, -8, -9, -9, -9, -8, -7, -5 ][ B + 4 ], [ -3, -1, 1, 3, 5, 3, 1, -1, -3 ][ B + 4 ] ) 22
23 24

Graph the following equation:

25 26
d53a57c Two doctypes were being output. Only output one. jeresig authored Apr 16, 2013 27
4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 28 graphInit({ 29 range: 11, 30 scale: 20, 31 axisArrows: "<->", 32 tickStep: 1, 33 labelStep: 1, 34 gridOpacity: 0.05, 35 axisOpacity: 0.2, 36 tickOpacity: 0.4, 37 labelOpacity: 0.5 38 }); 39 40 label( [ 0, 11 ], "y", "above" ); 41 label( [ 11, 0 ], "x", "right" ); 42 43 addMouseLayer(); 44 graph.pointA = addMovablePoint({ 45 coord: [ 5, 5 ], 46 snapX: 0.5, 47 snapY: 0.5, 48 normalStyle: { 49 stroke: KhanUtil.BLUE, 50 fill: KhanUtil.BLUE 51 } 52 }); 53 graph.pointB = addMovablePoint({ 54 coord: [ -5, 5 ], 55 snapX: 0.5, 56 snapY: 0.5, 57 normalStyle: { 58 stroke: KhanUtil.BLUE, 59 fill: KhanUtil.BLUE 60 } 61 }); 62 graph.pointC = addMovablePoint({ 63 coord: [ 0, 5 ], 64 snapX: 0.5, 65 snapY: 0.5, 66 normalStyle: { 67 stroke: KhanUtil.BLUE, 68 fill: KhanUtil.BLUE 69 } 70 }); 71 72 // returns true if the three points don't form a parabola (that opens vertically) 73 graph.invalid = function( p1, p2, p3 ) { 74 return ( ( p1[ 0 ] - p2[ 0 ] ) * ( p1[ 0 ] - p3[ 0 ] ) * ( p2[ 0 ] - p3[ 0 ] ) === 0 ); 75 }; 76 77 // Fits a parabola to 3 points 78 graph.fitParabola = function( p1, p2, p3 ) { 79 var denom = (p1[0] - p2[0]) * (p1[0] - p3[0]) * (p2[0] - p3[0]); 80 if ( denom !== 0 ) { 81 var A = (p3[0] * (p2[1] - p1[1]) + p2[0] * (p1[1] - p3[1]) + p1[0] * (p3[1] - p2[1])) / denom; 82 var B = ((p3[0] * p3[0]) * (p1[1] - p2[1]) + (p2[0] * p2[0]) * (p3[1] - p1[1]) + (p1[0] * p1[0]) * (p2[1] - p3[1])) / denom; 83 var C = (p2[0] * p3[0] * (p2[0] - p3[0]) * p1[1] + p3[0] * p1[0] * (p3[0] - p1[0]) * p2[1] + p1[0] * p2[0] * (p1[0] - p2[0]) * p3[1]) / denom; 84 return [ A, B, C ]; 85 } else { 86 return [ 0, 0, 0 ]; 87 } 88 }; 89 90 // A and B can't be in the same place 91 graph.pointA.onMove = function( x, y ) { 92 if ( graph.invalid( [ x, y ], graph.pointB.coord, graph.pointC.coord ) ) { 93 return false; 94 } 95 graph.pointA.coord = [ x, y ]; 96 graph.drawParabola(); 97 }; 98 graph.pointB.onMove = function( x, y ) { 99 if ( graph.invalid( graph.pointA.coord, [ x, y ], graph.pointC.coord ) ) { 100 return false; 101 } 102 graph.pointB.coord = [ x, y ]; 103 graph.drawParabola(); 104 }; 105 graph.pointC.onMove = function( x, y ) { 106 if ( graph.invalid( graph.pointA.coord, graph.pointB.coord, [ x, y ] ) ) { 107 return false; 108 } 109 graph.pointC.coord = [ x, y ]; 110 graph.drawParabola(); 111 }; 112 113 graph.parabola = bogusShape; 114 115 graph.drawParabola = function() { 116 graph.parabola.remove(); 117 var coeffs = graph.fitParabola( graph.pointA.coord, graph.pointB.coord, graph.pointC.coord ); 118 style({ 119 stroke: KhanUtil.BLUE 120 }, function() { b2647d2 Convert remaining parabola exercises and use coefficients for graphie… crm416 authored Oct 28, 2014 121 // Plot the parabola 122 var a = coeffs[0], b = coeffs[1], c = coeffs[2]; 123 graph.parabola = parabola(a, b, c); 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 124 graph.parabola.toBack(); 125 }); 126 }; 127 128 graph.drawParabola(); 129 130 graph.showSolution = function() { 131 $( "html, body" ).animate({ 132 scrollTop:$( ".question" ).offset().top 133 }, { 134 duration: 500, 135 easing: "swing", 136 complete: function() { 137 var coords = { 138 x1: graph.pointA.coord[0], 139 y1: graph.pointA.coord[1], 140 x2: graph.pointB.coord[0], 141 y2: graph.pointB.coord[1], 142 x3: graph.pointC.coord[0], 143 y3: graph.pointC.coord[1] 144 }; 145 $( coords ).delay( 100 ).animate({ 146 x1: 2, 147 y1: 2 * 2 + B * 2 + C, 148 x2: -2, 149 y2: -2 * -2 + B * -2 + C, 150 x3: 0, 151 y3: C 152 }, { 153 duration: 500, 154 easing: "linear", 155 step: function( now, fx ) { 156 coords[ fx.prop ] = now; 157 graph.pointA.setCoord([ coords.x1, coords.y1 ]); 158 graph.pointB.setCoord([ coords.x2, coords.y2 ]); 159 graph.pointC.setCoord([ coords.x3, coords.y3 ]); 160 graph.drawParabola(); 161 } 162 }); 163 } 164 }); 165 166 }; 167 168 169 170 0f0c630 Clean up the exercise files using the new cleaning utility. (II) cbhl authored Apr 16, 2013 171 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 172
173 Drag the three points to graph the equation. 174
175
[ graph.pointA.coord, graph.pointB.coord, graph.pointC.coord ]
176
177 var coeffs = graph.fitParabola( graph.pointA.coord, graph.pointB.coord, graph.pointC.coord ); 178 if ( coeffs[0] === 0 && coeffs[1] === 0 && coeffs[2] === 5 ) { 179 return ""; 180 } 181 return abs( A - coeffs[0] ) < 0.001 && abs( B - coeffs[1] ) < 0.001 && abs( C - coeffs[2] ) < 0.001; 182
183
184 graph.pointA.setCoord( guess[0] ); 185 graph.pointB.setCoord( guess[1] ); 186 graph.pointC.setCoord( guess[2] ); 187 graph.drawParabola(); 188
189
190 191
192
0f0c630 Clean up the exercise files using the new cleaning utility. (II) cbhl authored Apr 16, 2013 193
4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 194 195 y = plus( "x^2", B + "x", C ) 196 197 198 199 200 201 Create a table of x and y values by plugging different values of 202 x into the equation and plot each value: 203 204 62dae32 Clean up the exercise files using the new cleaning utility. (IV) cbhl authored Apr 16, 2013 205 x \hphantom{= } \quad y 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 206
207
0f0c630 Clean up the exercise files using the new cleaning utility. (II) cbhl authored Apr 16, 2013 208
4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 209 210 x 211 212 \color{BLUE}{plus( "(" + x + ")^2", B + "(" + x + ")", C )} 213 214 = \quad \color{PINK}{x * x + B * x + C} 215 0f0c630 Clean up the exercise files using the new cleaning utility. (II) cbhl authored Apr 16, 2013 216 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 217 var y = x * x + B * x + C; 218 style({ 219 stroke: PINK, 220 strokeWidth: 3 221 }, function() { 222 line( [ x - 0.3, y - 0.3 ], [ x + 0.3, y + 0.3 ] ).toBack(); 223 line( [ x - 0.3, y + 0.3 ], [ x + 0.3, y - 0.3 ] ).toBack(); 224 }); 225
226
227 228
229

230 There is only one graph of a parabola that passes through all of the (\color{GREEN}{x}, \color{PINK}{y}) points we plotted. 0f0c630 Clean up the exercise files using the new cleaning utility. (II) cbhl authored Apr 16, 2013 231
4e4cb9b lint: tabs->spaces and jQuery->\$ for exercises beneater authored Apr 10, 2012 232

233
234 235
236
237 238
f70a258 Add exercise: Graphing parabolas 0.5 beneater authored Mar 9, 2012 239 240
cde9e9f Re-run the exercises through the updated cleaner. jeresig authored Apr 24, 2013 241 242
Something went wrong with that request. Please try again.