We use logarithms to help us differentiate.
Logarithms were originally developed as a computational tool, mainly due to their
famous property:
\[ \log _b(xy) = \log _b(x)+\log _b(y). \]
Before the days of calculators and computers, this was critical knowledge for anyone
in a computational discipline.
Compute
\(138\cdot 23.4\) using logarithms.
Start by writing both numbers in scientific
notation
\[ \left (1.38\cdot 10^{2}\right )\cdot \left (2.34 \cdot 10^{1}\right ). \]
Next we use a log-table, which gives
\(\log _{10}(N)\) for values of
\(N\) ranging
between
\(0\) and
\(9\). We’ve reproduced part of such a table below.
From the table, we see that
\[ \log _{10}(1.38) \approx 0.1399\qquad \text {and}\qquad \log _{10}(2.34)\approx 0.3692 \]
Add these numbers together to get
\(0.5091\). Essentially, we
know the following at this point:
Using the table again, we see that \(\log _{10}(3.23)\approx 0.5091\). Since we were working in scientific notation, we
need to multiply this by \(10^3\). Our final answer is
\[ 3230 \approx 138\cdot 23.4 \]
Since
\(138\cdot 23.4 = 3229.2\), this is a good approximation.
The moral is:
Logarithms allow us to use addition in place of
multiplication.
1 Logarithmic differentiation
When taking derivatives, both the product rule and the quotient rule can be
cumbersome to use. Logarithms will save the day. A key point is the following
\[ \ddx \ln (f(x)) = \frac {1}{f(x)}\cdot f'(x) = \frac {f'(x)}{f(x)} \]
which
follows from the chain rule. Let’s look at an illustrative example to see how this is
actually used.
Compute:
\[ \ddx \frac {x^9e^{4x}}{\sqrt {x-4}} \]
Recall the properties of logarithms:
- \(\log _b(xy) = \log _b(x) + \log _b(y)\)
- \(\log _b(x/y) = \log _b(x) - \log _b(y)\)
- \(\log _b(x^y) = y\log _b(x)\)
While we could use the product and quotient rule to solve this problem, it would be
tedious. Start by taking the logarithm of the function to be differentiated.
\begin{align*} \ln \left (\frac {x^9e^{4x}}{\sqrt {x-4}} \right ) &= \ln \left (\answer [given]{x^9e^{4x}}\right ) - \ln \left (\answer [given]{\sqrt {x-4}}\right )\\ &= \ln \left (x^9\right )+\ln \left (e^{4x}\right ) - \ln \left ((x-4)^{1/2}\right )\\ &= \answer [given]{9}\ln (x)+4x - \answer [given]{\frac {1}{2}}\ln (x-4). \end{align*}
Setting \(f(x) = \frac {x^9e^{4x}}{\sqrt {x-4}}\), we can write
\[ \ln (f(x)) = 9\ln (x)+4x - \frac {1}{2}\ln (x-4).\]
Differentiating both sides, we find
\[ \frac {f'(x)}{f(x)} = \answer [given]{\frac {9}{x}+4} - \frac {1}{2(x-4)}.\]
Finally we solve for
\(f'(x)\), write
\[f'(x) = \left (\frac {9}{x}+4 - \frac {1}{2(x-4)}\right )\left (\answer [given]{\frac {x^9e^{4x}}{\sqrt {x-4}}}\right ). \]
The process above is called logarithmic differentiation. It starts by taking the
natural logarithm of the function, then using the properties of logarithms to
simplify. Logarithmic differentiation allows us to compute new derivatives,
too.
For
\(x>0\), compute:
\[ \ddx x^x \]
The function
\(x^x\) is tricky to differentiate. We cannot use the power rule,
as the exponent is not a constant; the function is not an exponential function
either, since the base is not a constant. However, if we set
\(f(x) = x^x\) we can write
\begin{align*} \ln (f(x)) &= \ln \left (x^x\right )\\ &=x\ln (x). \end{align*}
Differentiating both sides, we find
\[ \frac {f'(x)}{f(x)} = \answer [given]{1 + \ln (x)}. \]
Now we can solve for
\(f'(x)\),
\[ f'(x) = x^x + x^x\ln (x). \]
Alternative way: We can write
\[ x^x= e^{\ln (x^x)}=e^{x\ln (x)}. \]
Therefore,
\[ \ddx x^x=\ddx e^{x\ln (x)}=e^{x\ln (x)}\left (\ln (x)+1\right ), \]
by the Chain Rule and the Product
Rule.
Now, it follows that
\[ \ddx x^x=x^x\left (\answer [given]{\ln (x)+1}\right ). \]
The function from the previous example \(x^x\) is a type of function that we call a tower
function. Tower functions are functions written as \(f(x)^{g(x)}\), an exponential where both the
base and exponent depend on the variable. This logarithmic differentiation is one
method of differentiating a tower function. However we can also write
\[ f(x)^{g(x)} = e^{\ln \left ( f(x)^{g(x)} \right )} = e^{g(x)\ln ( f(x) ) }. \]
By
rewriting like this we can differentiate tower functions using chain rule and
product rule. In the previous example, the derivative of \(x^x\) was calculated in both
of these methods. Let’s differentiate one more tower functions using both
methods.
Calculate the derivative of
\(f(x) = x^{\cos (x)}\) in two ways: logarithmic differentiation and using chain
rule and product rule.
We start with the logarithmic differentiation method.
\begin{align*} \ln ( f(x) ) &= \ln \left ( x^{\cos (x)} \right ) \\ &= \cos (x) \ln (x) \end{align*}
Differentiating both sides gives:
\begin{align*} \dfrac {f'(x)}{f(x)} &= -\sin (x)\ln (x) + \dfrac {\cos (x)}{x} \\ f'(x) &= f(x)\left ( -\sin (x)\ln (x) + \dfrac {\cos (x)}{x}\right )\\ &= x^{\cos (x)} \left ( -\sin (x)\ln (x) + \dfrac {\cos (x)}{x}\right ) \end{align*}
Let’s differentiate \(f\) one more time, but using chain rule and product rule. We begin
by rewriting the tower function as an exponential with constant base \(e\).
\[ f(x) = x^{\cos (x)} = e^{\ln \left (x^{\cos (x)} \right )} = e^{\cos (x) \ln (x)} \]
Using chain
rule we find:
\begin{align*} f'(x) &= e^{\cos (x)\ln (x)}\left ( \cos (x)\ln (x)\right )'\\ &= e^{\cos (x)\ln (x)}\left ( -\sin (x) \ln (x) + \dfrac {\cos (x)}{x}\right ) \end{align*}
Rewriting \(e^{\cos (x)\ln (x)}\) as \(x^{\cos (x)}\), we see that both methods gave the same derivative \(f'\).
Compute:
\[ \ddx \ln {(|x|)} \]
The function
\(|x|\) is a piecewise defined function. If
\(x>0\) \begin{align*} \ddx \ln {(|x|)} &= \ddx \ln {(\answer [given]{x})}\\ &=\frac {1}{\answer [given]{x}}. \end{align*}
The function \(\ln {(|x|)}\) is not defined at \(x=0\). If \(x<0\)
\begin{align*} \ddx \ln {(|x|)} &= \ddx \ln {(\answer [given]{-x})}\\ &=\frac {-1}{\answer [given]{-x}}\\ &=\answer [given]{\frac {1}{x}}. \end{align*}
The next example will be useful when we want to use logarithmic differentiations for
functions that assume negative values.
Compute:
\[ \ddx \ln {(|f(x)|)} \]
By the previous example and the Chain Rule
\begin{align*} \ddx \ln {(|f(x)|)} &=\answer [given]{\frac {1}{f(x)}}\cdot f'(x).\\ &=\frac {f'(x)}{\answer [given]{f(x)}} \end{align*}
Compute:
\[ \ddx \left ( 6\sin ^2(x) + 3(x^2+1)^x(\cos (2x) + 3)^5\right ) \]
Notice the function here is the sum of two terms. The logarithm properties listed
above show that logarithms of products can be simplified, but logarithms of sums
cannot be. Instead of attempting logarithmic differentiation, let us use the Sum Rule
for derivatives to take the derivative of each term separately.
Call \(f(x) = 6\sin ^2(x) + 3(x^2+1)^x(\cos (2x) + 3)^5\), and the individual terms \(g(x) = 6\sin ^2(x)\) and \(h(x) = 3(x^2+1)^x(\cos (2x) + 3)^5\). That means \(f(x) = g(x) + h(x)\). The Sum Rule says \(\ddx f(x) = \ddx g(x) + \ddx h(x)\), so we
differentiate each term separately.
To calculate \(g'(x)\) we use Chain Rule:
\[ g'(x) = 12\sin (x)\cos (x). \]
To calculate \(h'(x)\) we use logarithmic differentiation (since \(h(x)\) is a product of factors each of
which are raised to powers, logarithms will help simplify this).
\begin{align*} \ln ( h(x) ) &= \ln \left ( 3(x^2+1)^x(\cos (2x) + 3)^5 \right ) \\ &= \ln \left ( 3\right ) + \ln \left ((x^2+1)^x\right ) + \ln \left ( (\cos (2x) + 3)^5 \right ) \\ &= \ln \left ( 3\right ) + x \ln (x^2+1) + 5 \ln (\cos (2x) + 3) \end{align*}
Then
\[ \ddx \ln ( h(x) ) = \ddx \left ( \ln \left ( 3\right ) + x \ln (x^2+1) + 5 \ln (\cos (2x) + 3) \right ) \]
which we calculate as:
\begin{align*} \dfrac {h'(x)}{h(x)} &= 0 + \left ( 1\cdot \ln (x^2+1) + x\cdot \dfrac {2x}{x^2+1}\right ) + 5 \cdot \dfrac {-2\sin (2x)}{\cos (2x)+3}\\ &= \ln (x^2+1) + \dfrac {2x^2}{x^2+1} -10 \dfrac {\sin (2x)}{\cos (2x)+3}\\ h'(x) &= h(x)\left (\ln (x^2+1) + \dfrac {2x^2}{x^2+1} -10 \dfrac {\sin (2x)}{\cos (2x)+3}\right )\\ &= \left (3(x^2+1)^x(\cos (2x) + 3)^5\right )\left (\ln (x^2+1) + \dfrac {2x^2}{x^2+1} -10 \dfrac {\sin (2x)}{\cos (2x)+3}\right ) \end{align*}
The derivative of the entire function is \(f'(x) = g'(x) + h'(x)\):
\begin{align*} &12\sin (x)\cos (x) + \\ &\left (3(x^2+1)^x(\cos (2x) + 3)^5\right )\left (\ln (x^2+1) + \dfrac {2x^2}{x^2+1} -10 \dfrac {\sin (2x)}{\cos (2x)+3}\right ). \end{align*}
2 Proof of the power rule
Finally, recall that previously we only proved the power rule for positive
integer exponents. Now we’ll use logarithmic differentiation to give a proof
for all real-valued exponents. We restate the power rule for convenience
sake:
Power Rule For any real number
\(n\),
\[ \ddx x^n = n x^{n-1}. \]
We will use logarithmic differentiation. Set \(f(x) = x^n\). Write
\begin{align*} \ln (|f(x)|) &= \ln \left (|x|^n\right ) , x\ne 0\\ &= n\ln (|x|). \end{align*}
Now differentiate both sides, and solve for \(f'(x)\)
\begin{align*} \frac {f'(x)}{f(x)} &= \frac {n}{x}\\ f'(x) &=\frac {n f(x)}{x}\\ &= \answer [given]{n x^{n-1}}. \end{align*}
Whenever \(x=0\) is in the domain of \(f\), the definition of the derivative at \(x=0\) implies that \(f'(0)=0\), if \(n\ne 1\)
and \(f'(0)=1\), if \(n=1\) , so the power rule applies to \(x=0\), too.
Thus we see that the power rule holds for all real-valued (nonzero) exponents.
While logarithmic differentiation might seem strange and new at first, with a little
practice it will seem much more natural to you.