Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 250 lines (237 sloc) 8.967 kB
d4e52bd @jeresig I got something to draw! A chart is showing up now, rendering content…
jeresig authored
1 <!DOCTYPE html>
6469103 @spicyj Limits 1 improvements, closes #258
spicyj authored
2 <html data-require="math graphie math-format expressions">
d4e52bd @jeresig I got something to draw! A chart is showing up now, rendering content…
jeresig authored
3 <head>
72418b8 @jeresig Add meta charset to all HTML pages.
jeresig authored
4 <meta charset="UTF-8" />
d4e52bd @jeresig I got something to draw! A chart is showing up now, rendering content…
jeresig authored
5 <title>Limits 1</title>
6 <script src="../khan-exercise.js"></script>
7 </head>
190610b @jeresig Retool framework, move Math and Graph logic out of khan-exercise.js a…
jeresig authored
8 <body>
9 <div class="exercise">
10 <div class="problems">
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
11 <div>
adcc771 @jeresig Implement problem-specific var blocks. Fixes #3.
jeresig authored
12 <div class="vars">
3601211 @osnr Rename nonzero random range function
osnr authored
13 <var id="q_lcoef">randRangeNonZero(-3, 3)</var>
adcc771 @jeresig Implement problem-specific var blocks. Fixes #3.
jeresig authored
14 <var id="edge">floor(sqrt(abs(10 / q_lcoef)))</var>
3601211 @osnr Rename nonzero random range function
osnr authored
15 <var id="l_cons">randRangeNonZero(-1 * edge, edge)</var>
adcc771 @jeresig Implement problem-specific var blocks. Fixes #3.
jeresig authored
16 <var id="quadratic">q_lcoef + 'x^2'</var>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
17 <var id="LINE">cleanMath('(x + ' + l_cons + ')')</var>
adcc771 @jeresig Implement problem-specific var blocks. Fixes #3.
jeresig authored
18 <var id="curFunc">function(x) {
19 return truncate_to_max(q_lcoef * Math.pow(x, 2), 4);
20 }</var>
21 <var id="a">-1 * l_cons</var>
22 <var id="limtoa">curFunc(a)</var>
23 <var id="l_limtoa">limtoa</var>
24 <var id="r_limtoa">limtoa</var>
25 </div>
cf02179 @spicyj Strip trailing whitespace
spicyj authored
26
3cd4d79 @spicyj graphie for limits_1
spicyj authored
27 <p><code>\displaystyle\lim_{x\to<var>a</var>} \dfrac{<var>quadratic</var><var>LINE</var>}{<var>LINE</var>} = {?}</code></p>
28 <div class="graphie" id="graph">
29 graphInit({
30 range: 10,
31 scale: 20,
32 tickStep: 1,
e6cf910 @spicyj Add some axis labels (close #459)
spicyj authored
33 labelStep: 1,
34 unityLabels: false,
35 labelFormat: function( s ) { return "\\small{" + s + "}"; },
761c7b2 @spicyj The *other* One True Way prevails (by decree of Sal)
spicyj authored
36 axisArrows: "<->"
3cd4d79 @spicyj graphie for limits_1
spicyj authored
37 });
38
39 style({
40 stroke: "#6495ed"
41 }, function() {
42 plot( function(x) {
43 return q_lcoef * x * x;
44 }, [-10, 10] );
45
46 circle( [a, limtoa], 4 / 20, { fill: "white" } )
47 });
9c227ad @jeresig Refine the definition of graphs, implement a basic API. Fixes #5.
jeresig authored
48 </div>
190610b @jeresig Retool framework, move Math and Graph logic out of khan-exercise.js a…
jeresig authored
49 <p class="solution"><code><var>limtoa</var></code></p>
50 <ul class="choices" data-show="5" data-none="true">
51 <li><code>0</code></li>
3601211 @osnr Rename nonzero random range function
osnr authored
52 <li><code><var>randRangeNonZero(-3, 3)</var></code></li>
53 <li><code><var>randRangeNonZero(-3, 3)</var></code></li>
190610b @jeresig Retool framework, move Math and Graph logic out of khan-exercise.js a…
jeresig authored
54 <li><code><var>q_lcoef</var></code></li>
55 <li><code><var>l_cons</var></code></li>
56 <li><code><var>curFunc(0)</var></code></li>
57 <li>Does not exist.</li>
58 </ul>
d4e52bd @jeresig I got something to draw! A chart is showing up now, rendering content…
jeresig authored
59 </div>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
60 <div>
61 <div class="vars">
3601211 @osnr Rename nonzero random range function
osnr authored
62 <var id="abs_coef">randRangeNonZero(-5, 5)</var>
63 <var id="abs_cons">randRangeNonZero(-7, 7)</var>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
64 <var id="curFunc">function(x) {
65 return x + abs_cons > 0 ?
66 abs_coef :
67 abs_coef * -1;
68 }</var>
69 <var id="a">abs_cons * -1</var>
70 <var id="limtoa">curFunc(a)</var>
71 <var id="l_limtoa">abs_coef * -1</var>
72 <var id="r_limtoa">abs_coef</var>
73 </div>
cf02179 @spicyj Strip trailing whitespace
spicyj authored
74
d639176 @spicyj small display changes for limits_1
spicyj authored
75 <p><code>\displaystyle \lim_{x\to<var>a</var>} \dfrac{<var>abs_coef</var>|x + <var>abs_cons</var>|}{x + <var>abs_cons</var>} = {?}</code></p>
3cd4d79 @spicyj graphie for limits_1
spicyj authored
76 <div class="graphie" id="graph">
77 graphInit({
78 range: 10,
79 scale: 20,
80 tickStep: 1,
e6cf910 @spicyj Add some axis labels (close #459)
spicyj authored
81 labelStep: 1,
82 unityLabels: false,
83 labelFormat: function( s ) { return "\\small{" + s + "}"; },
761c7b2 @spicyj The *other* One True Way prevails (by decree of Sal)
spicyj authored
84 axisArrows: "<->"
3cd4d79 @spicyj graphie for limits_1
spicyj authored
85 });
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
86
3cd4d79 @spicyj graphie for limits_1
spicyj authored
87 style({
88 stroke: "#6495ed"
89 }, function() {
90 line( [-11, abs_coef * -1], [-abs_cons, abs_coef * -1] );
91 line( [-abs_cons, abs_coef], [11, abs_coef] );
92
93 circle( [-abs_cons, -abs_coef], 4 / 20, { fill: "white" } )
94 circle( [-abs_cons, abs_coef], 4 / 20, { fill: "white" } )
95 });
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
96 </div>
97 <p class="solution">Does not exist.</p>
98 <ul class="choices" data-show="5" data-none="true">
99 <li><code>0</code></li>
100 <li><code><var>a</var></code></li>
101 <li><code><var>abs_cons</var></code></li>
102 <li><code><var>abs_coef</var></code></li>
103 <li><code><var>abs_coef * -1</var></code></li>
104 <li><code><var>abs_coef * abs_coef</var></code></li>
105 <li><code><var>abs_coef * abs_coef * -1</var></code></li>
3601211 @osnr Rename nonzero random range function
osnr authored
106 <li><code><var>randRangeNonZero(-3, 3)</var></code></li>
107 <li><code><var>randRangeNonZero(-3, 3)</var></code></li>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
108 </ul>
f4cce3f @jochu fix exercises to use new templating
jochu authored
109 <div class="hints" data-apply="appendContents">
3cd4d79 @spicyj graphie for limits_1
spicyj authored
110 <p id="final">The limit as we approach from the left doesn't match the limit as we approach from the right, so <code>f(x)</code> has no limit as <code>x \to <var>a</var></code>.</p>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
111 </div>
112 </div>
113 <div>
6469103 @spicyj Limits 1 improvements, closes #258
spicyj authored
114 <div class="vars" data-ensure="abs( limtoa ) < 10">
3601211 @osnr Rename nonzero random range function
osnr authored
115 <var id="l_coef">randRangeNonZero(-3, 3)</var>
116 <var id="l_cons">randRangeNonZero(-4, 4)</var>
117 <var id="d_cons">randRangeNonZero(-7, 7)</var>
6469103 @spicyj Limits 1 improvements, closes #258
spicyj authored
118 <var id="d_line">expr(["+", ["*", l_coef, "x"], l_cons])</var>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
119 <var id="curFunc">function(x) {
120 return l_coef * x + l_cons;
121 }</var>
122 <var id="a0">ceil((-10 - l_cons)/l_coef)</var>
123 <var id="a1">floor((10 - l_cons)/l_coef)</var>
6469103 @spicyj Limits 1 improvements, closes #258
spicyj authored
124 <var id="a" data-ensure="abs( a ) < 10">l_coef > 0 ? randRangeNonZero(a0, a1) : randRangeNonZero(a1, a0)</var>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
125 <var id="limtoa">curFunc(a)</var>
126 <var id="l_limtoa">limtoa</var>
127 <var id="r_limtoa">limtoa</var>
128 </div>
cf02179 @spicyj Strip trailing whitespace
spicyj authored
129
d639176 @spicyj small display changes for limits_1
spicyj authored
130 <p>If <code>f(x) = \begin{cases}
131 <var>d_cons</var> & \text{if $x = <var>a</var>$} \\
132 <var>d_line</var> & \text{otherwise}
133 \end{cases}</code>, find <code>\displaystyle \lim_{x \to <var>a</var>} f(x)</code>.</p>
3cd4d79 @spicyj graphie for limits_1
spicyj authored
134 <div class="graphie" id="graph">
135 graphInit({
136 range: 10,
137 scale: 20,
138 tickStep: 1,
e6cf910 @spicyj Add some axis labels (close #459)
spicyj authored
139 labelStep: 1,
140 unityLabels: false,
141 labelFormat: function( s ) { return "\\small{" + s + "}"; },
761c7b2 @spicyj The *other* One True Way prevails (by decree of Sal)
spicyj authored
142 axisArrows: "<->"
3cd4d79 @spicyj graphie for limits_1
spicyj authored
143 });
144
145 style({
146 stroke: "#6495ed"
147 }, function() {
148 plot( function(x) {
149 return l_coef * x + l_cons;
150 }, [-10, 10] );
151
152 circle( [a, limtoa], 4 / 20, { fill: "white" } )
153 circle( [a, d_cons], 4 / 20, { fill: "#6495ed", stroke: "none" } )
154 });
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
155 </div>
156 <p class="solution"><code><var>limtoa</var></code></p>
157 <ul class="choices" data-show="5" data-none="true">
158 <li><code>0</code></li>
159 <li><code><var>a</var></code></li>
160 <li><code><var>d_cons</var></code></li>
161 <li><code><var>l_coef</var></code></li>
7149ebc @jruberg replaced previous invocations of fraction with fractionReduce now tha…
jruberg authored
162 <li><code><var>fractionReduce(l_cons * -1, l_coef)</var></code></li>
3601211 @osnr Rename nonzero random range function
osnr authored
163 <li><code><var>randRangeNonZero(-3, 3)</var></code></li>
164 <li><code><var>randRangeNonZero(-3, 3)</var></code></li>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
165 <li>Does not exist.</li>
166 </ul>
167 </div>
168 <div>
6469103 @spicyj Limits 1 improvements, closes #258
spicyj authored
169 <div class="vars" data-ensure="abs( limtoa ) < 10">
3601211 @osnr Rename nonzero random range function
osnr authored
170 <var id="q_lcoef">randRangeNonZero(-3, 3)</var>
171 <var id="q_cons">randRangeNonZero(-3, 3)</var>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
172 <var id="edge">floor(sqrt(abs((10 - q_cons) / q_lcoef)))</var>
3601211 @osnr Rename nonzero random range function
osnr authored
173 <var id="a">randRangeNonZero(-1 * edge, edge)</var>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
174 <var id="curFunc">function(x) {
175 return q_lcoef * Math.pow(x, 2) + q_cons;
176 }</var>
177 <var id="limtoa">curFunc(a)</var>
178 <var id="l_limtoa">limtoa</var>
179 <var id="r_limtoa">limtoa</var>
180 </div>
181
6469103 @spicyj Limits 1 improvements, closes #258
spicyj authored
182 <p><code>\displaystyle \lim_{x\to<var>a</var>} <var>expr(["+", ["*", q_lcoef, ["^", "x", 2]], q_cons])</var> = {?}</code></p>
3cd4d79 @spicyj graphie for limits_1
spicyj authored
183 <div class="graphie" id="graph">
184 graphInit({
185 range: 10,
186 scale: 20,
187 tickStep: 1,
e6cf910 @spicyj Add some axis labels (close #459)
spicyj authored
188 labelStep: 1,
189 unityLabels: false,
190 labelFormat: function( s ) { return "\\small{" + s + "}"; },
761c7b2 @spicyj The *other* One True Way prevails (by decree of Sal)
spicyj authored
191 axisArrows: "<->"
3cd4d79 @spicyj graphie for limits_1
spicyj authored
192 });
193
194 style({
195 stroke: "#6495ed"
196 }, function() {
197 plot( function(x) {
198 return q_lcoef * x * x + q_cons;
199 }, [-10, 10] );
200 });
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
201 </div>
202 <p class="solution"><code><var>limtoa</var></code></p>
203 <ul class="choices" data-show="5" data-none="true">
204 <li><code>0</code></li>
205 <li><code><var>curFunc(0)</var></code></li>
3601211 @osnr Rename nonzero random range function
osnr authored
206 <li><code><var>randRangeNonZero(-3, 3)</var></code></li>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
207 <li><code><var>q_cons</var></code></li>
208 <li><code><var>q_cons * -1</var></code></li>
209 <li>Does not exist.</li>
210 </ul>
211 </div>
d4e52bd @jeresig I got something to draw! A chart is showing up now, rendering content…
jeresig authored
212 </div>
cf02179 @spicyj Strip trailing whitespace
spicyj authored
213
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
214 <div class="hints">
215 <div>
216 <p>What happens as we approach <code>x = <var>a</var></code> from the left?</p>
3cd4d79 @spicyj graphie for limits_1
spicyj authored
217 <div class="graphie" data-update="graph" data-style="stroke: orange; marker: arrow;">
218 line( [a - 2, 0], [a, 0], {
219 stroke: "#ff00af",
220 arrows: "->"
221 });
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
222 </div>
223 </div>
224 <div>
225 <table class="limit">
226 <tr><th><code>x</code></th><th><var>a - 0.1</var></th><th><var>a - 0.01</var></th><th><var>a - 0.001</var></th></tr>
227 <tr><th><code>f(x)</code></th><td><var>curFunc(a - 0.1).toFixed(4)</var></td><td><var>curFunc(a - 0.01).toFixed(4)</var></td><td><var>curFunc(a - 0.001).toFixed(4)</var></td></tr>
228 </table>
3cd4d79 @spicyj graphie for limits_1
spicyj authored
229 It looks like <code>f(x)</code> is approaching <code><var>l_limtoa</var></code> from the left.
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
230 </div>
231 <div>
232 <p>When we approach <code>x = <var>a</var></code> from the right, we get:</p>
233 <table class="limit">
234 <tr><th><code>x</code></th><th><var>a + 0.1</var></th><th><var>a + 0.01</var></th><th><var>a + 0.001</var></th></tr>
235 <tr><th><code>f(x)</code></th><td><var>curFunc(a + 0.1).toFixed(4)</var></td><td><var>curFunc(a + 0.01).toFixed(4)</var></td><td><var>curFunc(a + 0.001).toFixed(4)</var></td></tr>
236 </table>
3cd4d79 @spicyj graphie for limits_1
spicyj authored
237 It looks like <code>f(x)</code> is approaching <code><var>r_limtoa</var></code> from the right.
238 <div class="graphie" data-update="graph" data-style="stroke: orange; marker: arrow;">
239 line( [a + 2, 0], [a, 0], {
240 stroke: "#ff00af",
241 arrows: "->"
242 });
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
243 </div>
244 </div>
3cd4d79 @spicyj graphie for limits_1
spicyj authored
245 <p id="final">So the limit is <code><var>limtoa</var></code>.</p>
0ac33f7 @jeresig Finish implementing the Limits 1 exercise. Add some table formatting …
jeresig authored
246 </div>
d4e52bd @jeresig I got something to draw! A chart is showing up now, rendering content…
jeresig authored
247 </div>
248 </body>
4627f1f @osnr Move graph style stuff to the data-style attribute, so browsers don't…
osnr authored
249 </html>
Something went wrong with that request. Please try again.