# Taking the derivative of $\frac1{x} - \frac1{e^x-1}$ using the definition

Given $f$:

$$f(x) = \begin{cases} \frac1{x} - \frac1{e^x-1} & \text{if } x \neq 0 \\ \frac1{2} & \text{if } x = 0 \end{cases}$$

I have to find $f'(0)$ using the definition of derivative (i.e., limits). I already know how to differentiate and stuff, but I still can't figure out how to solve this. I know that I need to begin like this:

$$f'(0) = \lim_{h \to 0} \frac{f(h)-f(0)}{h} = \lim_{h \to 0} \frac{\frac1{h} - \frac1{e^h-1}-\frac1{2}}{h}$$

But I don't know how to do this. I feel like I should, but I can't figure it out. I tried distributing the denominator, I tried l'Hôpital's but I get $0$ as the answer, while according to what my prof gave me (this is homework) it should be $-\frac1{12}$. I really don't know how to deal with these limits; could someone give me a few tips?

-
Of course you cannot use L'Hopital, since that would involve the very derivative you are trying to compute. –  GEdgar Nov 8 '11 at 15:12

Please note the formula $(e^h.f)'=e^h(f+f')$.

$$\lim_{h\to0}\frac{e^h(2-h)-h-2}{2(e^h.h^2-h^2)}\quad(=\frac{0}{0})$$$$\lim_{h\to0}\frac{1}{2}\frac{e^h(1-h)-1}{e^h.(h^2+2h)-2h}\quad(=\frac{0}{0})$$$$\lim_{h\to0}\frac{1}{2}\frac{e^h(-h)}{e^h.(h^2+4h+2)-2}\quad(=\frac{0}{0})$$$$\lim_{h\to0}\frac{1}{2}\frac{e^h(-h-1)}{e^h.(h^2+6h+6)}\quad(=\frac{-1}{12})$$

-

A good strategy in such problems is to massage the problem into recognizable limits. (EDIT: I like this approach mainly because it avoids Taylor expansion and l'Hôpital's rule. This is, however, not the simplest approach.)

We can "simplify" given function as follows: $$\begin{eqnarray*} \frac{\frac{1}{x} - \frac{1}{e^x - 1} - \frac{1}{2}}{x} &=& \frac{(2-x)(e^x - 1) - 2x}{2x^2 (e^x - 1)} \\ &=& \frac{\color{Blue}{(2-x)}(e^x - 1)- \color{Blue}{(2-x)} \frac{2x}{2-x}}{\color{Red}{2} \ \color{Magenta}{x^2} \color{Green}{(e^x - 1)}} \\ &=& \frac{\color{Blue}{2-x}}{\color{Red}{2}} \cdot \frac{\color{Magenta}{x}}{\color{Green}{e^x - 1}} \cdot \frac{e^x - 1 - \frac{2x}{2-x}}{\color{Magenta}{x^3}}. \tag{1} \end{eqnarray*}$$ The first two factors both approach $1$ as $x \to 0$. Let us concentrate on the third factor. By Taylor expansion (or the formula for summing a geometric series), we have (for $|x| < 1$), $$\begin{eqnarray*} \frac{2x}{2-x} = \frac{x}{1 - x/2} &=& x + x \left(\frac{x}{2} \right) +x \left(\frac{x}{2} \right)^2 + x \left( \frac x 2 \right)^3 + \cdots \\ &=& \color{Red}{x + \frac{x^2}{2}} + \color{Blue}{x \left(\frac{x}{2} \right)^2 + x \left( \frac x 2 \right)^3 + \cdots} \\ &=& \color{Red}{x + \frac{x^2}{2}} + \color{Blue}{x \left(\frac{x}{2} \right)^2 \frac{1}{1 - \frac x 2}} \quad\quad \text{(summing the GP)} \\ &=& \color{Red}{x + \frac{x^2}{2}} \color{Blue}{+\frac{x^3}{2(2-x)}}. \tag{2} \end{eqnarray*}$$ (Though I used infinite GPs to obtain the final expression, one could verify it directly as well. In particular, the two expressions are equal for all $x \neq 2$, not just $|x| < 1$.) Plugging $(2)$ in $(1)$, we have $$\begin{eqnarray*} \frac{e^x - 1 - \frac{2x}{2-x}}{x^3} &=& \frac{e^x - 1 \color{Red}{- x - \frac{x^2}{2}} \color{Blue}{-\frac{x^3}{2(2-x)}}}{x^3} \\ &=& \frac{e^x - 1 \color{Red}{- x - \frac{x^2}{2}}}{x^3} \color{Blue}{-\frac{1}{2(2-x)}} \end{eqnarray*}$$ Once again, the second term has an easy limit of $\frac14$. The first term $$\frac{e^x - 1 - x - \frac{x^2}{2}}{x^3}$$ is also a standard limit. This limit can be evaluated using, say, the l'Hôpital's rule or using the Taylor expansion of $e^x$; it's value is $\frac{1}{3!}$. Plugging in both these limits, we can get the final answer to be $$\frac{1}{3!} - \frac{1}{4} = -\frac{1}{12}.$$

Bonus! If you wish to avoid Taylor expansion and l'Hôpital's rule even further, I will mention an "elementary" ways to evaluate limits such as $$\lim_{x \to 0} \frac{e^x - 1 - x}{x^2} \quad\text{and}\quad \lim_{x \to 0} \frac{e^x - 1 - x - \frac{x^2}{2}}{x^3}$$ assuming that these limits exists! (I stress that this is not a complete proof; yet I present it because I find the technique interesting.)

I will show the idea for the first limit, and leave the second one as an exercise. Suppose $A \stackrel{\text(def)}{=} \lim \limits_{x \to 0} \frac{e^x - 1 - x}{x^2}$ exists. Then $e^x = 1 + x + A x^2 + o(x^2)$. Therefore, by squaring: $$e^{2x} = (1 + x + A x^2 + o(x^2))^2 = \color{Red}{1} + \color{Blue}{2x} + \color{DarkGreen}{x^2 (1+2A)} + o(x^2) .$$ On the other hand, making the substitution $x \to 2x$ in the definition of the limit, we have $e^{2x} = \color{Red}{1} + \color{Blue}{2x} + \color{DarkGreen}{4A x^2} + o(x^2)$.

Equating the dominant terms in these two expressions, we must have $\color{DarkGreen}{4A} = \color{DarkGreen}{1 + 2A}$, which gives $A = \frac{1}{2}$.

-
If I don't mis-understood, the problem in this approach is to recognize which factors are to be omitted (evaluated) at which step. –  Tapu Nov 8 '11 at 4:21
A little typo (so little, that its embarrassing to mention) ...$O(x^2)$ should be $O(x^3)$ –  Tapu Nov 8 '11 at 4:41
No @Swapan, I used little-o, not big-O. I don't believe that there's a typo. (Although if it helps, you could pretend that the error terms are $O(x^3)$ instead of $o(x^2)$.) –  Srivatsan Nov 8 '11 at 4:43
You are correct @Srivatsan. I misunderstood at first glance. +1 for your nice explanation. –  Tapu Nov 8 '11 at 4:50
Thanks, that really helped. There's just one thing I don't understand: how do you get from $\frac{x}{1-\frac{x}{2}}$ to $x+\frac{x^2}{2}+\frac{x^3}{2(2-x)}$? –  Javier Nov 8 '11 at 13:38

This is just an exercise in persistence.

First note that

$$\lim_{h \to 0}\frac{\frac{1}{h} - \frac{1}{e^h - 1} - \frac{1}{2}}{h} = \lim_{h \to 0} \frac{2(e^h - 1)-2h - h(e^h - 1)}{2h^2 (e^h - 1)}$$

Applying L'Hopital's rule 4 or 5 times you end up with

$$\lim_{h \to 0}\frac{-1 - h}{4 + 8 + h + 4h + 2h^2} = - \frac{1}{12}.$$

-
No, 3 times suffices :) –  Tapu Nov 8 '11 at 4:17

Hmm, another approach, which seems simpler to me. However I'm not sure whether it is formally correct, so possibly someone else can also comment on this.

The key here is that the expression $\small {1 \over e^x-1 }$ is a very well known generation function for the bernoulli-numbers
$$\small {1 \over e^x-1 } = x^{-1} - 1/2 + {1 \over 12} x - {1 \over 720} x^3 + {1 \over 30240 }x^5 + O(x^7)$$

from where we can rewrite
$$\small \frac1x - {1 \over e^x-1 } = 1/2 - {1 \over 12} x + {1 \over 720} x^3 - {1 \over 30240 }x^5 + O(x^7) \qquad \text{ for } x \ne 0$$
and because by the second definition $\small f(x)=\frac12 \text{ for }x=0$ that power series is the analytic expression for both cases at and near that point.

Then the derivative can be taken termwise:
$$\small (\frac1x - {1 \over e^x-1 })' = - {1 \over 12} + {3 \over 720} x^2 - {5 \over 30240 }x^4 + O(x^6)$$
and is $\small -\frac1{12}$ at x=0

-