# Differentiation - L'Hôpital's rule

By Martin McBride, 2023-12-31
Tags: lhopitals rule first principles derivative limit indeterminate
Categories: differentiation calculus

We sometimes need to calculate the limit of the quotient of 2 functions:

Here we need to find the limit of f(x) divided by g(x) as x tends to the value c.

In most cases, this is fairly straightforward to calculate by simply substituting c for x. A problem occurs if both terms tend to 0 as x tends to c:

In this case, the limit is effectively zero divided by zero, which is indeterminate. However, L'Hôpital's rule allows us to calculate the limit in this particular case using the derivatives of f and g:

This will often yield a result that is not indeterminate, provided one or both of the derivatives is non-zero. Note that this formula is only valid if the original equation is indeterminate (and there are also additional conditions that we will cover later).

## Simple geometric interpretation

Let's take the following simple straight line functions:

Here is a graph of those 2 functions:

The diagonal magenta line is f. The steeper cyan line is g,

We can calculate f over g when x = 3. The values of f and g are shown as points A and B on the graph. The value of f over g is 1/2 in this case:

We can repeat the calculation for x = 2. The values of f and g are shown as points C and D on the graph. The value of f over g this time is still 1/2:

In general, if we pick any value of x (except 1) we will find that f over g is 1/2. But, as we can see from the graph, when x = 1 both f and g are 0 so we can't calculate the ratio, it is indeterminate:

We can, however, find the limit as x tends towards 1. As we move from AB to CD, we move closer to x = 1, but the ratio of f and g remains the same, 1/2. If we were to move even closer, the ratio would remain at 1/2. We could get as close to x = 1 as we wanted, the ratio would still be 1/2. So, informally, we can say that the limit as x tends to 1 is 1/2:

Notice that this is only the case because both lines cross the x-axis at the same point (that happens to be x = 1). If the two functions cross the x-axis at different points, the ratio of f and g would not be constant as x changed. But this would also mean that the ratio would never be indeterminate.

So here is what we have learned from this example. If two straight lines f and g both cross the x-axis at the same point c then:

1. The ratio of f(x) to g(x) at any point x (other than c) is equal to the ratio of the slope of f to the slope of g.
2. The limit of the ratio as x tends to c is also equal to the ratio of the slope of f to the slope of g.

Before we leave this example, we should be aware that there is a simpler solution that doesn't involve limits. If we write out the full equations of f and g, we see that the terms in x cancel out:

The only reason for using straight lines is to illustrate the rule in a very simple case. We will now look at a more complex case.

## Using L'Hôpital's rule

L'Hôpital's rule works in a similar way to the previous example but can extend to functions other than straight lines. We will take this example:

The quotient of these two functions is therefore:

Here is a plot of the functions, again the f(x) (the curve) is magenta and the straight line g(x) is cyan:

We can see that both functions are 0 at x = 0, so the quotient is indeterminate at that point. We will use L'Hôpital's rule to find the limit of the quotient at 0. This requires us to differentiate the two functions:

We are using the fact that the derivative of the exponential function is itself, and of course the derivative of 2x is simply 2.

L'Hôpital's rule says that the limit of the quotient as x tends to 0 is equal to the limit of the quotient of the derivatives as x tends to 0. We can find this limit by simply evaluating the derivatives at 0:

We know that e to the power 0 is 1 because any non-zero number raised to the power 0 is 1. So the limit of the quotient as x tends to 0 is 1/2.

This result is the same as the previous one, and that is deliberate. To understand why it works, let's zoom in on the graph. As often happens, when we zoom in on a curve f(x), it starts to resemble a straight line:

Let's zoom in even more:

The f(x) curve now looks very much like a straight line, especially the section that is close to the origin. More specifically, it looks like a straight line whose slope is equal to the derivative of f at the origin, f'(0). This slope, as we already know, is 1. For illustration, the black dotted line has a slope of 1.

This results in a limiting value of 1/2 for the quotient as x approaches 0.

## Conditions for applying L'Hôpital's rule

There are 4 conditions that must all be satisfied for L'Hôpital's rule to apply. All 4 conditions are necessary.

Condition 1 - the quotient of f(x) and g(x) must be indeterminate at the point on interest c. We have seen why this is true above.

This occurs if f(x) and g(x) both tend to 0 as x approaches c, as we have seen. A similar situation occurs when f(x) and g(x) both tend to infinity or minus infinity as x approaches c. There are several other indeterminate forms that we will discuss later. L'Hôpital's rule can be applied in all these cases.

Condition 2 - f(x) and g(x) must be differentiable close to c.

The rule works by finding the derivatives f'(x) and g'(x), and calculating the limit of the quotient as x tends to c, so both functions must be differentiable.

For this to be possible, there must be some open interval I, containing c, where f and g are differentiable. For example:

This shows an exponential function (magenta) and the tan function (cyan) that are both 0 at x = π. The tan function isn't differentiable everywhere, but it is differentiable over certain intervals. For example, it is differentiable over the interval I of (2.5, 3.5) shown in grey, and this region includes the point of interest, c.

It doesn't matter how small the interval I is, provided there is some interval around c where f and g are differentiable.

As an aside, we don't require f(x) and g(x) to be differentiable when x exactly equals c. This is because we are only interested in the limit as x approaches c. If the functions are differentiable everywhere in I except c, that is sufficient

Condition 3 - The derivative g'(x) must not be 0 close to c. Again this means that there must be some open interval I, containing c, where g'(x) is never 0. And again, it doesn't matter if g'(c) is 0.

Condition 4 - the limit of the quotient of derivatives must exist. Certain functions do not have limits. For example, the function sin(x) as x tends to infinity has no limit. The sine function oscillates between 1 and -1. L'Hôpital's rule cannot be applied if either of the derivatives has this type of behaviour.

## Proof

We will look at a simple proof of the rule for the case where f and g are continuously differentiable around c, and where g'(c) is not zero. This doesn't cover every case, but it applies to many cases involving commonly used functions such as polynomials, exponentials, sine and cosine, etc.

We are aiming to prove that:

We will start by expressing the LHS like this:

All we have done here is substitute x with c + h, where h is a small value that tends to 0 as x tends to c.

Now we know f and g are zero when x = c:

This means that we can subtract f(c) and g(c) from the top and bottom without changing the result:

Next, we divide the top and bottom by h:

Notice that the top term is the standard formula for the first derivative of f:

And of course, the bottom term is the first derivative of g. So the limit of the quotient as x tends to c is equal to the value of the quotient of the derivatives when x equals c:

Since we have specified that f and g are continuously differentiable, we can express the derivative at c as the limit as x tends to c, which gives us the required result:

## Repeated application

Consider this case:

The limit is indeterminate (0 over 0) so we apply L'Hôpital's rule using:

This gives the following result:

Unfortunately, this quotient is also indeterminate at 0, because 2x is 0 and sin(x) is 0 at that point. So we can't find our answer directly. But notice that the new formula is also a quotient of 2 functions that we will call p and q:

The derivatives of these functions are:

So L'Hôpital's rule for p and q is:

This gives a limit of 2.

We don't need to explicitly define new functions p and q, this was just done here to illustrate the point. We just need to know that we can apply L'Hôpital's rule twice in succession:

Sometimes we might need to apply the rule 3 or more times to find the answer.

## Other indeterminate cases

There are other types of indeterminate limits, for example:

In this case, as x tends to infinity, the top and bottom terms both tend to infinity, so the result is indeterminate. We can apply L'Hôpital's rule, like this:

Differentiating top and bottom gives a limit of e to the x, which of course tends to infinity as x increases.

It is sometimes possible to apply the rule to other indeterminate forms, for example:

These will be the subject of a later article.