# publicelizabethslavitt/khan-exercises forked from Khan/khan-exercises

### Subversion checkout URL

You can clone with HTTPS or Subversion.

commit 346c6d9ec32bc693407d3537d5e876748b4be9a0 2 parents 21f62d7 + 4c9cd87
authored November 28, 2011

Showing 2 changed files with 124 additions and 1 deletion.

1. exercises/lhopitals_rule.html
120  exercises/lhopitals_rule.html
 ... ... @@ -0,0 +1,120 @@ 1 + 2 + 3 + 4 +  5 + L'Hopital's Rule 6 +  7 + 8 + 9 +
10 +
11 +
12 +
13 + randFromArray([ 0, Infinity ]) 14 + { 0: "0", Infinity: "\\infty" }[ APPROACHES ] 15 + "\\frac" + { 0: "{0}{0}", Infinity: "{\\infty}{\\infty}" }[ APPROACHES ] 16 + 17 +  20 + KhanUtil.randRange( 2, 3 ) 21 + new KhanUtil.Polynomial( DEGREE - 1, DEGREE, KhanUtil.randCoefs( DEGREE - 1, DEGREE ), "x" ) 22 + 23 +  27 +  28 + new KhanUtil.Polynomial( DEGREE - 1, DEGREE, KhanUtil.randCoefs( DEGREE - 1, DEGREE ), "x" ) 29 +  30 + 31 +  34 +  35 + (function() { 36 + var steps = [[ NUMERATOR, DENOMINATOR ]]; 37 + var n = NUMERATOR, d = DENOMINATOR; 38 + 39 + // In an x approaches zero problem we only care when 40 + // minDegree is 0 (i.e. there is a plain number 41 + // in the denominator so we can evaluate the expression), 42 + // in an approaches infinity problem we want maxDegree to be 43 + // 0 as well 44 + 45 + while ( d.findMinDegree() !== 0 || ( APPROACHES === 0 ? false : d.findMaxDegree() !== 0 ) ) { 46 + n = KhanUtil.ddxPolynomial( n ); 47 + d = KhanUtil.ddxPolynomial( d ); 48 + steps.push([ n, d ]); 49 + } 50 + 51 + return steps; 52 + })() 53 +  54 + 55 + STEPS[ STEPS.length - 1 ][ 0 ] 56 + STEPS[ STEPS.length - 1 ][ 1 ] 57 + 58 +  59 + SLN_NUMERATOR_TEXT.evalOf( 0 ) 60 + SLN_DENOMINATOR_TEXT.evalOf( 0 ) 61 + reduces( SLN_NUMERATOR, SLN_DENOMINATOR ) || SLN_NUMERATOR < 0 || SLN_DENOMINATOR < 0 || abs( SLN_DENOMINATOR ) === 1 62 +
63 + 64 +
65 +  66 +

67 + \displaystyle \lim_{x \to APPROACHES_TEXT} \frac{NUMERATOR}{DENOMINATOR} = {?} 68 +

69 + 70 +

SLN_NUMERATOR / SLN_DENOMINATOR

71 +
72 + 73 +
74 +  75 +

L'Hopital's rule states that since evaluating 76 +  77 + \displaystyle \lim_{x \to APPROACHES_TEXT} \frac{NUMERATOR}{DENOMINATOR} = INDETERMINATE_FORM,
78 +  79 + if \displaystyle \lim_{x \to APPROACHES_TEXT} \frac{\frac{d}{dx} (NUMERATOR)}{\frac{d}{dx} (DENOMINATOR)} exists, evaluating it will give us the actual limit. 80 +

81 + 82 +  83 +

84 + Repeat this process until evaluating the limit will not result in an indeterminate form:
85 +  86 +  87 +  88 + \displaystyle\frac{\frac{d}{dx} (STEP[0])}{\frac{d}{dx} (STEP[1])} = 89 + \frac{STEPS[N+1][0]}{STEPS[N+1][1]} 90 +  91 +
92 +  93 +
Since evaluating the limit at this point still results in INDETERMINATE_FORM, we must apply L'Hopital's rule again:
94 +
95 +
96 +
97 +

98 + 99 +  100 +

101 +  102 + Evaluate the limit: 103 +  104 + \displaystyle \lim_{x \to APPROACHES_TEXT} \frac{SLN_NUMERATOR_TEXT.text()}{SLN_DENOMINATOR_TEXT.text()} 105 +  106 +  107 + = \frac{SLN_NUMERATOR_TEXT.text().replace("x", "(0)")}{SLN_DENOMINATOR_TEXT.text().replace("x", "(0)")} = 108 +  109 + \frac{SLN_NUMERATOR}{SLN_DENOMINATOR} 110 +  111 +  112 + = fractionReduce( SLN_NUMERATOR, SLN_DENOMINATOR ) 113 +  114 +

115 +
116 +
117 +
118 +
119 + 120 +
 @@ -101,7 +101,10 @@ jQuery.extend( Khan.answerTypes, { 101 101  .replace( /\u2212/, "-" ) 102 102   103 103  // Remove space after +, - 104 - .replace( /([+-])\s+/g, "$1" ); 104 + .replace( /([+-])\s+/g, "$1" ) 105 + 106 + // Remove leading/trailing whitespace 107 + .replace(/(^\s*)|(\s*$)/gi,""); 105 108   106 109  // Extract numerator and denominator 107 110  var match = text.match( /^([+-]?\d+)\s*\/\s*([+-]?\d+)$/ );