{% extends "limits_1.html" %} {% block limitfunctions %} functions[0] = function() { funcType = 4; // n_order polynomial / d_order polynomial // dominance test num = ''; denom = ''; rnum = ''; // num and denom divided by highest-degree x rdenom = ''; n_order = getRandomIntRange(1, 4); if (getRandomIntRange(0, 1)) { // 50% chance we get dominance d_order = getRandomIntRange(1, 4); if (d_order > n_order) { high_order = d_order; } else { high_order = n_order; } } else { d_order = n_order; high_order = n_order; } n_coefs = new Array(); for (var i = n_order; i > 0; i--) { n_coefs[i] = nonZeroRandomInt(-3, 3); num = num + n_coefs[i] + 'x^' + i + ' + '; if (i == high_order) { rnum = rnum + n_coefs[i] + ' + '; } else { rnum = rnum + n_coefs[i] + '/(x^' + (high_order - i) + ') + '; } } num = nicefy_signs(num.substring(0, num.length - 2)); rnum = nicefy_signs(rnum.substring(0, rnum.length - 2)); d_coefs = new Array(); for (var i = d_order; i > 0; i--) { d_coefs[i] = nonZeroRandomInt(-3, 3); denom = denom + d_coefs[i] + 'x^' + i + ' + '; if (i == high_order) { rdenom = rdenom + d_coefs[i] + ' + '; } else { rdenom = rdenom + d_coefs[i] + '/(x^' + (high_order - i) + ') + '; } } denom = nicefy_signs(denom.substring(0, denom.length - 2)); rdenom = nicefy_signs(rdenom.substring(0, rdenom.length - 2)); if (getRandomIntRange(0, 1)) { // 50% chance of approaching -inf rather than inf a = 'oo'; if (n_order > d_order) { // check signs of coefficients if (n_coefs[n_order] * d_coefs[d_order] > 0) { limtoa = 'oo'; } else { limtoa = '-oo'; } } else if (d_order > n_order) { limtoa = 0; } else { limtoa = format_fraction(n_coefs[n_order], d_coefs[d_order]); } } else { a = '-oo'; if (n_order > d_order) { if (n_coefs[n_order] * d_coefs[d_order] > 0) { limtoa = '-oo'; } else { limtoa = 'oo'; } } else if (d_order > n_order) { limtoa = 0; } else { limtoa = format_fraction(n_coefs[n_order], d_coefs[d_order]); } } // don't need curFunc setCorrectAnswer(limtoa); addWrongChoice(format_fraction(n_coefs[n_order], d_coefs[d_order])); addWrongChoice(format_fraction(n_coefs[n_order] * -1, d_coefs[d_order])); addWrongChoice(format_fraction(d_coefs[d_order], n_coefs[n_order])); addWrongChoice(format_fraction(d_coefs[d_order] * -1, n_coefs[n_order])); addWrongChoice('oo'); addWrongChoice('-oo'); addWrongChoice(0); addWrongChoice(1); return '(' + num + ')/(' + denom + ')'; } functions[1] = function() { funcType = 5; // c / (x + b) c = nonZeroRandomInt(-7, 7); b = nonZeroRandomInt(-7, 7); curFunc = function(x) { return c / (x + b); } a = b * -1; if (curFunc(a - 0.01) > 0) { // +oo from the left, -oo from the right l_limtoa = 'oo'; r_limtoa = '-oo'; limtoa = '`does not exist`'; } else { r_limtoa = 'oo'; l_limtoa = '-oo'; limtoa = '`does not exist`'; } setCorrectAnswer(limtoa); addWrongChoice('oo'); addWrongChoice('-oo'); addWrongChoice(a); addWrongChoice(b); addWrongChoice(c); addWrongChoice(0); addWrongChoice(format_fraction(c, b)); return nicefy_signs(c + '/(x + ' + b + ')'); } functions[2] = function() { funcType = 6; // c / |x + b| var c = nonZeroRandomInt(-7, 7); var b = nonZeroRandomInt(-7, 7); curFunc = function(x) { return c / Math.abs(x + b); } a = b * -1; if (c > 0) { // +oo l_limtoa = r_limtoa = limtoa = 'oo'; } else { l_limtoa = r_limtoa = limtoa = '-oo'; } setCorrectAnswer(limtoa); addWrongChoice('oo'); addWrongChoice('-oo'); addWrongChoice(a); addWrongChoice(b); addWrongChoice(c); addWrongChoice(0); addWrongChoice(format_fraction(c, b)); plotExp = nicefy_signs(c + '/abs(x + ' + b + ')'); return nicefy_signs(c + '/(|x + ' + b + '|)'); } {% endblock limitfunctions %} {% block hints %} if (funcType == 4) { // analytical solution degX = '1/(x^' + high_order + ')'; write_step( '
Divide `f(x)`\'s numerator and denominator by the largest degree of `x` in either:
' + '`f(x) = ((' + num + ')(' + degX + '))/((' + denom + ')(' + degX + '))`
' + '`f(x) = (' + rnum + ')/(' + rdenom + ')
'); write_step( 'All of the terms with `x` in the denominator will approach 0 as `x->' + a + '`,
' + 'so `lim_(x->' + a + ') f(x) = lim_(x->' + a + ') (' + rnum + ')/(' + rdenom + ') = ' + limtoa + '`
'); } else { // left-right solution, but with the proper notation write_step('What happens as we approach `x=' + a + '` from the left?'); write_step( '| `x` | ' + (a - 0.1) + ' | ' + (a - 0.01) + ' | ' + (a - 0.001) + ' |
| `f(x)` | ' + curFunc(a - 0.1).toFixed(4) + ' | ' + curFunc(a - 0.01).toFixed(4) + ' | ' + curFunc(a - 0.001).toFixed(4) + ' |
| `x` | ' + (a + 0.1) + ' | ' + (a + 0.01) + ' | ' + (a + 0.001) + ' |
| `f(x)` | ' + curFunc(a + 0.1).toFixed(4) + ' | ' + curFunc(a + 0.01).toFixed(4) + ' | ' + curFunc(a + 0.001).toFixed(4) + ' |
`lim_(x->' + a + '^-) ' + curExp + ' != lim_(x->' + a + '^+) ' + curExp + ',
' + 'so `lim_(x->' + a + ') ' + curExp + '` doesn\'t exist.
'); } else { write_step('So `lim_(x->' + a + ') ' + curExp + '=' + limtoa + '`'); } } {% endblock hints %} {% block graphlimit %} if (getRandomIntRange(0, 1)) { // 50% chance we graph if (funcType != 6) { // have to substitute abs() for || // so we have a different plotExp for function 6 plotExp = curExp; } if (funcType == 5 || funcType == 6) { // asciisvg draws the asymptote for some reason, // so we have to exclude it present.plot(plotExp, -11, a - 0.2); present.plot(plotExp, a + 0.2, 11); } else { present.plot(plotExp); } } else { document.getElementById('present').style.display = 'none'; } {% endblock graphlimit %} {% block hintfunction %} if (funcType != 4) { // if we have a hint that needs a graph, then graph draw_next_step(); } else { give_next_step(); } {% endblock hintfunction %}