PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/khan-exercises/khan-exercises/exercises/graphing_systems_of_equations.html

https://gitlab.com/gregtyka/lfmawordpress
HTML | 299 lines | 288 code | 11 blank | 0 comment | 0 complexity | 7c9a9064ed9bc22ce2ea3cf049b6d3c5 MD5 | raw file
  1. <!DOCTYPE html>
  2. <html data-require="math math-format expressions graphie interactive">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5. <title>Graphing systems of equations</title>
  6. <script src="../khan-exercise.js"></script>
  7. </head>
  8. <body>
  9. <div class="exercise">
  10. <div class="problems">
  11. <div id="standard" data-weight="4">
  12. <div class="vars">
  13. <div data-ensure="( YINT_1 + SLOPE_1_FRAC[0] <= 10 ) && ( YINT_2 + SLOPE_2_FRAC[0] <= 10 ) && ( YINT_1 + SLOPE_1_FRAC[0] >= -10 ) && ( YINT_2 + SLOPE_2_FRAC[0] >= -10 )">
  14. <var id="X">randRangeNonZero( -5, 5 )</var>
  15. <var id="Y">randRange( -5, 5 )</var>
  16. <div data-ensure="( abs(YINT_1 - YINT_2) > 3 ) && ( YINT_1 !== Y ) && ( YINT_2 !== Y )">
  17. <var id="YINT_1">randRangeNonZero( -5, 5 )</var>
  18. <var id="YINT_2">randRangeNonZero( -5, 5 )</var>
  19. </div>
  20. <var id="SLOPE_1">(Y - YINT_1) / X</var>
  21. <var id="SLOPE_2">(Y - YINT_2) / X</var>
  22. <var id="SLOPE_1_FRAC">toFraction( SLOPE_1, 0.001 )</var>
  23. <var id="SLOPE_2_FRAC">toFraction( SLOPE_2, 0.001 )</var>
  24. </div>
  25. <var id="PRETTY_SLOPE_1">SLOPE_1 === 1 ? "" : ( SLOPE_1 === -1 ? "-" : decimalFraction( SLOPE_1, true, true ) )</var>
  26. <var id="PRETTY_SLOPE_2">SLOPE_2 === 1 ? "" : ( SLOPE_2 === -1 ? "-" : decimalFraction( SLOPE_2, true, true ) )</var>
  27. <var id="MULT_1">randRangeNonZero( -2, 2 )</var>
  28. <var id="MULT_2">randRangeNonZero( -2, 2 )</var>
  29. <var id="A1">( Y - YINT_1 ) * -MULT_1</var>
  30. <var id="A2">( Y - YINT_2 ) * -MULT_2</var>
  31. <var id="B1">X * MULT_1</var>
  32. <var id="B2">X * MULT_2</var>
  33. <var id="C1">X * YINT_1 * MULT_1</var>
  34. <var id="C2">X * YINT_2 * MULT_2</var>
  35. <var id="STD_FORM_1">true</var>
  36. <var id="STD_FORM_2">true</var>
  37. </div>
  38. <p class="question">Graph this system of equations and solve.</p>
  39. <div class="problem">
  40. <p class="hint_blue" data-if="STD_FORM_1">
  41. <code><var>expr([ "+", [ "*", A1, "x" ], [ "*", B1, "y" ] ])</var> = <var>C1</var></code>
  42. </p>
  43. <p class="hint_blue" data-else>
  44. <code>y = <var>PRETTY_SLOPE_1</var> x + <var>YINT_1</var></code>
  45. </p>
  46. <p class="hint_green" data-if="STD_FORM_2">
  47. <code><var>expr([ "+", [ "*", A2, "x" ], [ "*", B2, "y" ] ])</var> = <var>C2</var></code>
  48. </p>
  49. <p class="hint_green" data-else>
  50. <code>y = <var>PRETTY_SLOPE_2</var> x + <var>YINT_2</var></code>
  51. </p>
  52. <div class="graphie" id="grid">
  53. graphInit({
  54. range: 11,
  55. scale: 20,
  56. axisArrows: "&lt;-&gt;",
  57. tickStep: 1,
  58. labelStep: 1
  59. });
  60. addMouseLayer();
  61. graph.pointA = addMovablePoint({
  62. coord: [ -5, 5 ],
  63. snapX: 0.5,
  64. snapY: 0.5,
  65. normalStyle: {
  66. stroke: KhanUtil.BLUE,
  67. fill: KhanUtil.BLUE
  68. }
  69. });
  70. graph.pointB = addMovablePoint({
  71. coord: [ 5, 5 ],
  72. snapX: 0.5,
  73. snapY: 0.5,
  74. normalStyle: {
  75. stroke: KhanUtil.BLUE,
  76. fill: KhanUtil.BLUE
  77. }
  78. });
  79. graph.pointC = addMovablePoint({
  80. coord: [ -5, -5 ],
  81. snapX: 0.5,
  82. snapY: 0.5,
  83. normalStyle: {
  84. stroke: KhanUtil.GREEN,
  85. fill: KhanUtil.GREEN
  86. }
  87. });
  88. graph.pointD = addMovablePoint({
  89. coord: [ 5, -5 ],
  90. snapX: 0.5,
  91. snapY: 0.5,
  92. normalStyle: {
  93. stroke: KhanUtil.GREEN,
  94. fill: KhanUtil.GREEN
  95. }
  96. });
  97. graph.line1 = addMovableLineSegment({
  98. pointA: graph.pointA,
  99. pointZ: graph.pointB,
  100. fixed: true,
  101. extendLine: true
  102. });
  103. graph.line2 = addMovableLineSegment({
  104. pointA: graph.pointC,
  105. pointZ: graph.pointD,
  106. fixed: true,
  107. extendLine: true,
  108. normalStyle: {
  109. "stroke": KhanUtil.GREEN,
  110. "stroke-width": 2
  111. }
  112. });
  113. // A and B can't be in the same place
  114. graph.pointA.onMove = function( x, y ) {
  115. return ( x != graph.pointB.coord[0] || y != graph.pointB.coord[1] );
  116. }
  117. graph.pointB.onMove = function( x, y ) {
  118. return ( x != graph.pointA.coord[0] || y != graph.pointA.coord[1] );
  119. }
  120. // C and D can't be in the same place
  121. graph.pointC.onMove = function( x, y ) {
  122. return ( x != graph.pointD.coord[0] || y != graph.pointD.coord[1] );
  123. }
  124. graph.pointD.onMove = function( x, y ) {
  125. return ( x != graph.pointC.coord[0] || y != graph.pointC.coord[1] );
  126. }
  127. graph.pointC.toFront();
  128. graph.pointD.toFront();
  129. graph.pointA.toFront();
  130. graph.pointB.toFront();
  131. </div>
  132. Click and drag the points to move the lines.
  133. </div>
  134. <div class="solution" data-type="multiple">
  135. <p><code>x = </code> <span class="sol"><var>X</var></span></p>
  136. <p><code>y = </code> <span class="sol"><var>Y</var></span></p>
  137. <div class="sol" data-type="custom">
  138. <div class="instruction">
  139. Your graphs are also part of your answer.
  140. </div>
  141. <div class="guess">
  142. [ graph.pointA.coord, graph.pointB.coord, graph.pointC.coord, graph.pointD.coord ]
  143. </div>
  144. <div class="validator-function">
  145. var slope1 = ( guess[1][1] - guess[0][1] ) / ( guess[1][0] - guess[0][0] );
  146. var slope2 = ( guess[3][1] - guess[2][1] ) / ( guess[3][0] - guess[2][0] );
  147. var yint1 = slope1 * ( 0 - guess[0][0] ) + guess[0][1];
  148. var yint2 = slope2 * ( 0 - guess[2][0] ) + guess[2][1];
  149. // allows blue function to be graphed with green line and vice versa, fwiw
  150. return ( abs( SLOPE_1 - slope1 ) &lt; 0.001
  151. &amp;&amp; abs( SLOPE_2 - slope2 ) &lt; 0.001
  152. &amp;&amp; abs( YINT_1 - yint1 ) &lt; 0.001
  153. &amp;&amp; abs( YINT_2 - yint2 ) &lt; 0.001 )
  154. || ( abs( SLOPE_1 - slope2 ) &lt; 0.001
  155. &amp;&amp; abs( SLOPE_2 - slope1 ) &lt; 0.001
  156. &amp;&amp; abs( YINT_2 - yint1 ) &lt; 0.001
  157. &amp;&amp; abs( YINT_1 - yint2 ) &lt; 0.001 );
  158. </div>
  159. <div class="show-guess">
  160. graph.pointA.setCoord( guess[0] );
  161. graph.pointB.setCoord( guess[1] );
  162. graph.pointC.setCoord( guess[2] );
  163. graph.pointD.setCoord( guess[3] );
  164. graph.line1.transform( true );
  165. graph.line2.transform( true );
  166. </div>
  167. </div>
  168. <div class="example">two integers like <code>6</code></div>
  169. </div>
  170. </div>
  171. <div id="slope-intercept" data-type="standard" data-weight="5">
  172. <div class="vars">
  173. <var id="STD_FORM_1">false</var>
  174. <var id="STD_FORM_2">false</var>
  175. </div>
  176. </div>
  177. <div id="mixed" data-type="standard" data-weight="1">
  178. <div class="vars">
  179. <var id="STD_FORM_1">random() &lt; 0.5 ? true : false</var>
  180. <var id="STD_FORM_2">!STD_FORM_1</var>
  181. </div>
  182. </div>
  183. </div>
  184. <div class="hints">
  185. <div data-if="STD_FORM_1" data-unwrap>
  186. <p class="hint_blue">
  187. Convert the first equation,
  188. <code><var>expr([ "+", [ "*", A1, "x" ], [ "*", B1, "y" ] ])</var> = <var>C1</var></code>,
  189. to slope-intercept form.
  190. </p>
  191. <p class="hint_blue"><code>y = <var>PRETTY_SLOPE_1</var> x + <var>YINT_1</var></code></p>
  192. </div>
  193. <p class="hint_blue">
  194. The y-intercept for the first equation is <code><var>YINT_1</var></code>, so the first line
  195. must pass through the point <code>(0, <var>YINT_1</var>)</code>.
  196. </p>
  197. <p class="hint_blue">
  198. The slope for the first equation is <code><var>decimalFraction( SLOPE_1, true, true )</var></code>. Remember that
  199. the slope tells you rise over run. So in this case for every
  200. <code><var>abs( SLOPE_1_FRAC[0] )</var></code>
  201. <var>"position" + ( abs( SLOPE_1_FRAC[0] ) !== 1 ? "s" : "" )</var>
  202. you move
  203. <span data-if="SLOPE_1_FRAC[0] < 0"><em>down</em> (because it's negative)</span>
  204. <span data-else>up</span>
  205. you must also move
  206. <code><var>SLOPE_1_FRAC[1]</var></code>
  207. <var>"position" + ( abs( SLOPE_1_FRAC[1] ) !== 1 ? "s" : "" )</var>
  208. to the right.
  209. </p>
  210. <p class="hint_blue">
  211. <code><var>SLOPE_1_FRAC[1]</var></code>
  212. <var>"position" + ( abs( SLOPE_1_FRAC[1] ) !== 1 ? "s" : "" )</var> to the right and
  213. <code><var>abs( SLOPE_1_FRAC[0] )</var></code>
  214. <var>"position" + ( abs( SLOPE_1_FRAC[0] ) !== 1 ? "s" : "" )</var>
  215. <span data-if="SLOPE_1_FRAC[0] < 0">down</span><span data-else>up</span> from
  216. <code>(0, <var>YINT_1</var>)</code> is
  217. <code>(<var>SLOPE_1_FRAC[1]</var>, <var>YINT_1 + SLOPE_1_FRAC[0]</var>)</code>.
  218. </p>
  219. <p class="hint_blue">
  220. Graph the blue line so it passes through
  221. <code>(0, <var>YINT_1</var>)</code> and
  222. <code>(<var>SLOPE_1_FRAC[1]</var>, <var>YINT_1 + SLOPE_1_FRAC[0]</var>)</code>.
  223. <br /><input type="button" value="Show me" onClick="javascript:
  224. KhanUtil.currentGraph.graph.pointA.moveTo( 0, KhanUtil.tmpl.getVAR( 'YINT_1' ), true );
  225. KhanUtil.currentGraph.graph.pointB.moveTo( KhanUtil.tmpl.getVAR( 'SLOPE_1_FRAC[1]' ),
  226. KhanUtil.tmpl.getVAR( 'YINT_1' ) + KhanUtil.tmpl.getVAR( 'SLOPE_1_FRAC[0]' ), true );
  227. " />
  228. </p>
  229. <div data-if="STD_FORM_2" data-unwrap>
  230. <p class="hint_green">
  231. Convert the second equation,
  232. <code><var>expr([ "+", [ "*", A2, "x" ], [ "*", B2, "y" ] ])</var> = <var>C2</var></code>,
  233. to slope-intercept form.
  234. </p>
  235. <p class="hint_green"><code>y = <var>PRETTY_SLOPE_2</var> x + <var>YINT_2</var></code></p>
  236. </div>
  237. <p class="hint_green">
  238. The y-intercept for the second equation is <code><var>YINT_2</var></code>, so the second line
  239. must pass through the point <code>(0, <var>YINT_2</var>)</code>.
  240. </p>
  241. <p class="hint_green">
  242. The slope for the second equation is <code><var>decimalFraction( SLOPE_2, true, true )</var></code>. Remember that
  243. the slope tells you rise over run. So in this case for every
  244. <code><var>abs( SLOPE_2_FRAC[0] )</var></code>
  245. <var>"position" + ( abs( SLOPE_2_FRAC[0] ) !== 1 ? "s" : "" )</var>
  246. you move
  247. <span data-if="SLOPE_2_FRAC[0] < 0"><em>down</em> (because it's negative)</span>
  248. <span data-else>up</span>
  249. you must also move
  250. <code><var>SLOPE_2_FRAC[1]</var></code>
  251. <var>"position" + ( abs( SLOPE_1_FRAC[1] ) !== 1 ? "s" : "" )</var>
  252. to the right.
  253. </p>
  254. <p class="hint_green">
  255. <code><var>SLOPE_2_FRAC[1]</var></code>
  256. <var>"position" + ( abs( SLOPE_2_FRAC[1] ) !== 1 ? "s" : "" )</var> to the right and
  257. <code><var>abs( SLOPE_2_FRAC[0] )</var></code>
  258. <var>"position" + ( abs( SLOPE_2_FRAC[0] ) !== 1 ? "s" : "" )</var>
  259. <span data-if="SLOPE_2_FRAC[0] < 0">down</span><span data-else>up</span> from
  260. <code>(0, <var>YINT_2</var>)</code> is
  261. <code>(<var>SLOPE_2_FRAC[1]</var>, <var>YINT_2 + SLOPE_2_FRAC[0]</var>)</code>.
  262. </p>
  263. <p class="hint_green">
  264. Graph the green line so it passes through
  265. <code>(0, <var>YINT_2</var>)</code> and
  266. <code>(<var>SLOPE_2_FRAC[1]</var>, <var>YINT_2 + SLOPE_2_FRAC[0]</var>)</code>.
  267. <br /><input type="button" value="Show me" onClick="javascript:
  268. KhanUtil.currentGraph.graph.pointC.moveTo( 0, KhanUtil.tmpl.getVAR( 'YINT_2' ), true );
  269. KhanUtil.currentGraph.graph.pointD.moveTo( KhanUtil.tmpl.getVAR( 'SLOPE_2_FRAC[1]' ),
  270. KhanUtil.tmpl.getVAR( 'YINT_2' ) + KhanUtil.tmpl.getVAR( 'SLOPE_2_FRAC[0]' ), true );
  271. " />
  272. </p>
  273. <p>
  274. The solution is the point where the two lines intersect.
  275. </p>
  276. <div>
  277. <p>
  278. The lines intersect at <code class="hint_pink">(<var>X</var>, <var>Y</var>)</code>.
  279. </p>
  280. <div class="graphie" data-update="grid">
  281. style({ stroke: PINK });
  282. circle( [ X, Y ], 0.5 );
  283. </div>
  284. </div>
  285. </div>
  286. </div>
  287. </body>
  288. </html>