Laboratory 10
L'Hôpital's Rule

Introduction

    The purpose of this lab is to learn how to evaluate limits of the form lim_ (xc) f(x)/g(x) that we were unable to evaluate previously. In particular, we shall learn how to evaluate these limits either when f(c) = g(c) = 0 or when Underscript[lim, xc] f(x) = lim_ (xc) g(x) = ∞. Limits of this type often occur in practice. In addition, there are many other types of limits which we previously could not evaluate that can be converted into limits in one of these two forms; we shall also examine these.  

Example 10.1, Motivation.

    Suppose that we want to evaluate lim_ (x0) (e^x - 1)/(sin πx). We see that the numerator e^x - 1 and the denominator sin x both vanish when x = 0, so we can not simply substitute x = 0 into this quotient as the resulting expression 0/0 is not defined. When previously faced with such limits, we would try to use some algebra to manipulate the numerator and denominator into a form that would allow us to evaluate the limit by using direct substitution. At first glance, this method seems to fail us here. Indeed, we know of no method to relate sin πx and e^x - 1. Or do we?

    Since we are taking a limit, we only need to know the values of the numerator and denominator near the point x = 0. One idea then, is to replace the numerator and denominator with simpler functions that agree with them near the origin. The hope would then be that the limit of the resulting expression could be evaluated directly. In fact, with one slight modification, this is exactly what we shall do. We know from our study of the derivative that the tangent line to a function gives a good approximation to that function, at least in a neighborhood of that function. Thus, we shall replace both the numerator and denominator in our example by the equations of the corresponding tangent lines, and then evaluate the limit of the resulting quotient.
    
    We begin by finding the equation of the tangent line to f(x) = e^x - 1 at the point x = 0.

Clear[f, ftan] f[x_] := E^x - 1

ftan[x_] := f[0] + f '[0] * (x - 0)

For comparison, we draw the graph of f(x) (in red) and the graph of ftan(x), the tangent line to f(x) (in blue) below.

Plot[{f[x], ftan[x]}, {x, -1, 1}, PlotStyle-> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}] ;

[Graphics:HTMLFiles/index_21.gif]

Now we do the same thing for g(x) = sin πx.

Clear[g, gtan] g[x_] := Sin[π x]

General :: spell1 : Possible spelling error: new symbol name \"gtan\" is similar to existing symbol \"ftan\".

We can ignore the warning message that Mathematica gives us; we know that the symbols have similar spellings. We now define the equation of the tangent line, and again give a graph comparing g(x) with its tangent line at x = 0.

gtan[x_] := g[0] + g '[0] * (x - 0) ; Plot[{g[x], gtan[x]}, {x, -1, 1}, PlotStyle-> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}] ;

[Graphics:HTMLFiles/index_28.gif]

    Now, because f(x) ≈ftan(x) and because g(x) ≈gtan(x), and also because these approximations get better the closer x gets to zero, we hope that lim_ (x0) f(x)/g(x) = lim_ (x0) ftan(x)/gtan(x), and that we can easily evaluate this second limit. Well, we first check what ftan(x) and gtan(x) are:

ftan[x]

x

gtan[x]

π x

This is encouraging; we can see simply that

ftan[x]/gtan[x]

1/π

so that lim_ (x0) ftan(x)/gtan(x) = 1/π. We still need to know however, if this actually gives us the limit lim_ (x0) f(x)/g(x). To check this, we shall draw a graph of both f(x)/g(x) and y = 1/π on the same axes.

Plot[{f[x]/g[x], 1/π}, {x, -0.2, 0.2}, PlotStyle-> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}] ;

[Graphics:HTMLFiles/index_46.gif]

If we zoom in a bit, we find the following:

Plot[{f[x]/g[x], 1/π}, {x, -0.02, 0.02}, PlotStyle-> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}] ;

[Graphics:HTMLFiles/index_48.gif]

This gives us some graphical evidence to conclude that our idea is correct, and that lim_ (x0) f(x)/g(x) = 1/π. Note that it is unclear from the graph if the function f(x)/g(x) is defined at x = 0; however we already know that this quotient is not defined when x = 0. Simply because the graph that Mathematica produces appears to be defined at x = 0, we can not conclude that the function is defined there.

Experiment 10.1

    Repeat the process of Example 10.1 to estimate the limit lim_ (x1) (x^2 + x - 2)/(ln x). In particular, find tangent line approximations for the numerator and denominator. Evaluate the limit of the quotient of the tangent line approximations, and verify your result graphically.

Example 10.2, The Basic Rule

    Although the methods we have learned so far are useful, they are somewhat cumbersome, as they require a number of intermediate calculations. In this section we shall look for ways to simplify what we have already discussed.
    Suppose that we want to evaluate a limit of the form lim_ (xc) f(x)/g(x)  for functions f(x) and g(x) with f(c) = g(c) = 0 using the techniques that we have discussed. We know that the first thing to do is to find the tangent line approximation to f(x) at x = c. This approximation has the form
    ftan(x) = f(c) + f ' (c) (x - c).
We then do the same thing for the function g(x), giving us
    gtan(x) = g(c) + g ' (c) (x - c) .
The limit we want is then
    lim_ (xc) ftan(x)/gtan(x) = lim_ (xc) (f(c) + f ' (c) (x - c))/(g(c) + g ' (c) (x - c)).
Here is where we notice something interesting. Because f(c) = g(c) = 0, we can simplify this expression to read
    lim_ (xc) ftan(x)/gtan(x) = (f ' (c))/(g ' (c)) .
As a consequence, it seems that we ought to be able to evaluate lim_ (xc) f(x)/g(x) when f(c) = g(c) = 0 by simply calculating the ratio (f ' (c))/(g ' (c)). Well, it turns out that this is almost true. In the arguments leading up to this conclusion we have made a number of simplifications which need not all be true. However, the basic ideas are correct, and carefully reworking them, we can prove the following statement, called L'Hôpital's Rule:

    L'Hôpital's Rule (Basic Version): Let f(x) and g(x) be differentiable on an interval (a, b) containing the point c, except possibly at the point c, with g ' (x) ≠0 for all x in the interval, except possibly for the point c. If f(c) = g(c) = 0, then
    
lim_ (xc) f(x)/g(x) = lim_ (xc) (f ' (x))/(g ' (x))
provided the limit on the right side exists or is infinite.

    This rule can be proven to be true using something called the Cauchy Mean Value Theorem. We shall not dwell on the proof, but instead shall focus on the uses of this rule in applications.

    We can apply L'Hôpital's rule to our limit in Example 10.1 as follows. Recall that there we wanted to calculate lim_ (x0) (e^x - 1)/(sin πx). Start by setting f(x) = e^x - 1, and g(x) = sin πx.

Clear[f, g] f[x_] := E^x - 1 g[x_] := Sin[π x]

Clearly f(0) = g(0) = 0. Next we check that g ' (x) ≠0 on some interval containing the point x = 0 graphically.

Plot[g '[x], {x, -1, 1}] ;

[Graphics:HTMLFiles/index_88.gif]

Since g ' (x) ≠0 in the interval (-0.5,0.5), we can apply L'Hôpital's Rule. First we note that

f '[x]/g '[x]

(E^x Sec[π x])/π

Then we evaluate lim_ (xc) (f ' (x))/(g ' (x)) by directly substituting x = 0

f '[x]/g '[x] /. x->0

1/π

so we conclude that lim_ (x0) (e^x - 1)/(sin πx) = 1/π.

    For another example, suppose we wish to calculate lim_ (x0) (sin^(-1) x)/x. We can not directly substitute x = 0 because the denominator would vanish. Instead we do this as follows:

Clear[f, g] f[x_] := ArcSin[x] ; g[x_] := x

Direct calculation shows us that f(0) = g(0) = 0. Since g ' (x) = 1 we know that it is nonzero; thus we can apply L'Hôpital's Rule. First we calculate

f '[x]/g '[x]

1/(1 - x^2)^(1/2)

We then evaluate lim_ (xc) (f ' (x))/(g ' (x)) by direct substitution

f '[x]/g '[x] /. x-> 0

1

and we conclude that lim_ (x0) (sin^(-1) x)/x = 1. We can verify this graphically should we choose to do so, but this is unnecessary, as L'Hôpital's Rule can be proven to be true.

Plot[ArcSin[x]/x, {x, -1, 1}] ;

[Graphics:HTMLFiles/index_109.gif]

Experiment 10.2

    Use L'Hôpital's Rule to calculate each of the following limits. Verify your results graphically.

    1. lim_ (x0) (sin 2x)/(x cos x)
    
    2. lim_ (x0) (tan x)/x
    
    3. lim_ (x1) (sin πx)/(ln x)

Example 10.3, Variants of the Main Rule

    There are a number of minor variations of L'Hôpital's Rule which we would now like to discuss.

    First, we point out that L'Hôpital's Rule works just as well when the value of the limit is infinite. Indeed, consider lim_ (x1) (ln x)/(x - 1)^3.

Clear[f, g] f[x_] := Log[x] ; g[x_] := (x - 1)^3

Plot[g '[x], {x, 0, 2}] ;

[Graphics:HTMLFiles/index_116.gif]

Because g ' (x) ≠0 for x≠1, and because f(1) = g(1) = 0 we can apply L'Hôpital's Rule

f '[x]/g '[x]

1/(3 (-1 + x)^2 x)

We then see that f ' (x)/g ' (x) ∞ as x1. We can verify this graphically as follows.

Plot[f[x]/g[x], {x, 0, 2}] ;

[Graphics:HTMLFiles/index_125.gif]

    Next, we point out that L'Hôpital's Rule also applies to one sided limits as well as to two-sided limits. As an example, consider the question of finding  lim_ (x0^+) (sin πx)/x^(1/2)

Clear[f, g] f[x_] := Sin[Pi x] g[x_] := Sqrt[x]

Plot[g '[x], {x, 0, 1}] ;

[Graphics:HTMLFiles/index_129.gif]

Since f(0) = g(0) = 0, and since g ' (x) ≠0, we can apply L'Hôpital's Rule.

f '[x]/g '[x]

2 π x^(1/2) Cos[π x]

Direct substitution then gives us

f '[x]/g '[x] /. x->0

0

so that the limit is 0. We again verify this graphically.

Plot[f[x]/g[x], {x, 0, 0.2}] ;

[Graphics:HTMLFiles/index_137.gif]

    Next, we point out that L'Hôpital's Rule is also valid for limits at infinity. As an example of this, consider the limit lim_ (x∞) (-π/2 + tan^(-1) e^x)/e^(-x) .

Clear[f, g] f[x_] := ArcTan[E^x] - Pi/2 g[x_] := E^(-x)

Plot[{f[x], g[x]}, {x, 1, 10}, PlotStyle-> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}] ;

[Graphics:HTMLFiles/index_142.gif]

Because f(x) 0 and g(x) 0 as x∞, our limit has the required indeterminate form 0/0. We still need to check that g ' (x) ≠0, however

g '[x]

-E^(-x)

so this is satisfied. We then apply L'Hôpital's Rule.

f '[x]/g '[x]

-E^(2 x)/(1 + E^(2 x))

We see that f ' (x)/g ' (x)  -1 as x∞; indeed, we can rewrite our quotient using the Apart command

Apart[f '[x]/g '[x]]

-1 + 1/(1 + E^(2 x))

and we see that the second term tends to zero as x tends to infinity. Once again, we verify our calculation by examining the graph.

Plot[f[x]/g[x], {x, 1, 10}] ;

[Graphics:HTMLFiles/index_158.gif]

Experiment 10.3

    Use L'Hôpital's Rule to calculate each of the following limits. Verify your result graphically.

    a) lim_ (x0^+) (1 - e^x)/x^2.
    
    b) lim_ (x1^-) (ln x)/(1 - x)^(1/2).

Example 10.4, The General Rule

    All of the limits we have discussed so far have been of the form lim_ (xc) f(x)/g(x) where f(c) = g(c) = 0. We say that these quotients are of the indeterminate form 0/0. So far, we have learned how to find limits in this indeterminate form with the aid of L'Hôpital's Rule. It turns out that L'Hôpital's Rule is even more general than this. In particular, it can be used to evaluate limits which have the indeterminate form ∞/∞. Stated precisely, we have the following.

    L'Hôpital's Rule (General Version): Let f(x) and g(x) be differentiable on an interval (a, b) containing the point c, except possibly at the point c, with g ' (x) ≠0 for all x in the interval, except possibly for the point c. If either f(c) = g(c) = 0, or lim_ (xc) f(x) = lim_ (xc) g(x) = ± ∞, then
    
lim_ (xc) f(x)/g(x) = lim_ (xc) (f ' (x))/(g ' (x))
provided the limit on the right side exists or is infinite. This remains true if the limits are one-sided limits or if the limit is taken as
x ± ∞.

    We can now use this general rule to evaluate even more limits. As an example, consider lim_ (x∞) e^x/x . Although this is not in the form discussed in Example 10.2, because e^x∞ as x∞,  it does fit the hypotheses of the general version of L'Hôpital's Rule.

Clear[f, g] f[x_] := E^x ; g[x_] := x

f '[x]/g '[x]

E^x

Limit[f '[x]/g '[x], x->∞]

∞

As a consequence, we conclude that lim_ (x∞) e^x/x = ∞. We verify this by examining the graph.

Plot[f[x]/g[x], {x, 0, 10}] ;

[Graphics:HTMLFiles/index_187.gif]

    As another example, consider lim_ (x∞) (ln x)/x^2. Because both ln x∞ and x^2∞ as x∞, our limit has the indeterminate form ∞/∞, and L'Hôpital's Rule applies.

Clear[f, g] ; f[x_] := Log[x] ; g[x_] := x^2

f '[x]/g '[x]

1/(2 x^2)

Limit[f '[x]/g '[x], x->∞]

0

We see that lim_ (x∞) (ln x)/x^2 = 0; once again we check our work by plotting the graph.

Plot[f[x]/g[x], {x, 1, 100}] ;

[Graphics:HTMLFiles/index_200.gif]

    When using L'Hôpital's Rule, it is important to check that the function actually has one of the indeterminate forms 0/0 or ∞/∞. If it does not have one of these forms, you can not use L'Hôpital's Rule; this is a common error. Indeed, suppose that we wanted to calculate lim_ (x0) (x - 19)/(x + 7). Simply substituting the value x = 0 lets us see that lim_ (x0) (x - 19)/(x + 7) = -19/7. On the other hand, if we were to differentiate the numerator and denominator, and evaluate the limit of that quotient, we obtain lim_ (x0) 1/1 = 1, which is clearly wrong.

Experiment 10.4

    Evaluate each of the following limits with the aid of the general form of L'Hôpital's Rule. Verify your results by examining a graph.

    a) lim_ (x∞) x^2/e^(x^2 + 1)
    
    b) lim_ (x0^+) (ln x)/x^(-1/2)

Example 10.5

    Sometimes, when we apply L'Hôpital's Rule to a limit, the resulting expression does not have a limit that can be evaluated directly. Indeed, consider lim_ (x0^+) (ln x)/ln(2e^x - 2). If we try to evaluate this limit using L'Hôpital's Rule, we find the following.

Clear[f, g] f[x_] := Log[x] ; g[x_] := Log[2 E^x - 2]

Plot[g '[x], {x, 0, 1}] ;

[Graphics:HTMLFiles/index_212.gif]

Since f(x) ∞ and g(x) ∞ as x0^+, our limit has the indeterminate form ∞/∞, and we can apply the general form of L'Hôpital's Rule.

f '[x]/g '[x]

(E^(-x) (-2 + 2 E^x))/(2 x)

Simplify[%]

(1 - E^(-x))/x

Unfortunately, we can not evaluate lim_ (x0^+) (1 - e^(-x))/x by directly substituting in the value x = 0. Indeed, this new limit is also indeterminate and has the form 0/0. We then evaluate this limit by, once again, applying L'Hôpital's Rule.

Clear[f1, g1] f1[x_] := 1 - E^(-x) ; g1[x_] := x ;

f1 '[x]/g1 '[x]

E^(-x)

f1 '[x]/g1 '[x] /. x->0

1

Thus we conclude that lim_ (x0^+) (ln x)/ln(2e^x - 2) = lim_ (x0^+) (1 - e^(-x))/x = 1. We can verify this by plotting a graph.

Plot[f[x]/g[x], {x, 0, 0.1}] ;

[Graphics:HTMLFiles/index_231.gif]

Plot[f1[x]/g1[x], {x, 0, 0.1}] ;

[Graphics:HTMLFiles/index_233.gif]

    There are other limits which can be evaluated by appealing to L'Hôpital's Rule, but only after the function undergoes a preliminary algebraic massage. Indeed, consider lim_ (xπ/2^-) (sec x - tan x). We can not evaluate this by direct substitution because lim_ (xπ/2^-) sec x = lim_ (xπ/2^-) tan x = ∞. However, we can evaluate this if we rewrite it in a form amenable to L'Hôpital's Rule. Indeed, writing our limit solely in terms of sines and cosines, we find that
    sec x - tan x = (1 - sin x)/(cos x) .
Then because cos π/2 = 1 - sin π/2 = 0, we can apply L'Hôpital's Rule.

Clear[f, g] f[x_] := 1 - Sin[x] ; g[x_] := Cos[x]

Plot[g '[x], {x, 0, 1}] ;

[Graphics:HTMLFiles/index_240.gif]

f '[x]/g '[x]

Cot[x]

f '[x]/g '[x] /. x->Pi/2

0

    As a consequence, we conclude that lim_ (xπ/2^-) (sec x - tan x) = 0. We can verify this graphically.

Plot[Sec[x] - Tan[x], {x, 0, Pi/2}] ;

[Graphics:HTMLFiles/index_247.gif]

    Sometimes more drastic action is needed to rewrite a limit in a form to which we can apply L'Hôpital's Rule. For example, consider lim_ (x0^+) (1 + x)^(1/x). As it stands, this is not in a form which we can evaluate directly, nor is it in a form to which we can apply L'Hôpital's Rule. However, the logarithm of this function is something which we can understand. Indeed, if we set

h[x_] := (1 + x)^(1/x)

then

Log[h[x]]

Log[(1 + x)^1/x]

can be expanded as

PowerExpand[Log[h[x]]]

Log[1 + x]/x

In this form, we see that ln h(x) is in a form amenable to analysis with L'Hôpital's Rule. Then, because e^x is a continuous function,

    lim_ (x0^+) (1 + x)^(1/x) = lim_ (x0^+) h(x) = lim_ (x0^+) exp(ln(h(x))) = exp(lim_ (x0^+) ln(h(x))).

We can find our original limit by finding the exponential of the limit of ln(h(x)), which we have already seen is in a form to which we can apply L'Hôpital's Rule. (Remember that the function exp(x) is the same as e^x, so that exp(x) = e^x.)

    To find the limit of ln(h(x)) = ln(1 + x)/x, we note that it is a quotient and has the indeterminate form 0/0 so L'Hôpital's Rule applies.

Clear[f, g] f[x_] := Log[1 + x] ; g[x_] := x

f '[x]/g '[x]

1/(1 + x)

f '[x]/g '[x] /. x->0

1

As a consequence, we conclude that lim_ (x0^+) ln(h(x)) = lim_ (x0^+) ln(1 + x)/x = 1, and thus lim_ (x0^+) (1 + x)^(1/x) = exp(lim_ (x0^+) ln(h(x))) = exp(1) = e.

    We can verify that we have calculated our limit correctly by drawing a graph. Here we display the function (1 + x)^(1/x) in red and the constant line y = e in blue.

Plot[{h[x], E}, {x, 0, 0.1}, PlotStyle-> {RGBColor[1, 0, 0], RGBColor[0, 0, 1]}] ;

[Graphics:HTMLFiles/index_273.gif]

Experiment 10.5

    Use the tools we have learned to evaluate each of the following limits. In each case give a graph to support your claim.

    1. lim_ (x0) (cos x - 1)/(x + 2x^2)
    
    2. lim_ (x∞)[1/x - 1/x^(1/2)]
    
    3. lim_ (x∞) (x - (x^2 + x)^(1/2))
    
    4. lim_ (x0) (csc x - 1/x)

Credits

These laboratories were created by Raouf Boules, Geoff Goodson, Ohoe Kim and Mike O'Leary for use in the Calculus courses of Towson University. Commercial use is prohibited without permission of the authors. Non-commercial use is permitted, provided this credit section is retained.


Created by Mathematica  (August 23, 2004)