Differentiation of a Logarithm

Show the derivation of the derivative of the natural logarithm

Let \(y=\ln x\). To differentiate, we follow the steps:

Step 1: \[y+\Delta y=\ln(x+\Delta x)\] Step 2:
\[\begin{align} \Delta y & =\ln(x+\Delta x)-\ln x\\ & =\ln\left(\frac{x+\Delta x}{x}\right)\\ & =\ln\left(1+\frac{\Delta x}{x}\right)\end{align}\]
Step 3:
\[\begin{align} \frac{\Delta y}{\Delta x} & =\frac{1}{\Delta x}\ln\left(1+\frac{\Delta x}{x}\right)\\ & =\ln\left(1+\frac{\Delta x}{x}\right)^{1/\Delta x}\\ & =\frac{1}{x}\ln\left(1+\frac{\Delta x}{x}\right)^{\frac{x}{\Delta x}}\end{align}\]
Dividing the logarithm by \(x\) and at the same time multiplying the exponent of the parentheses by \(x\) changes the form of the expression but not its value. That is, \(\ln u=\frac{1}{a}\ln u^{a}\).] Step 4:
\[\begin{align} \frac{dy}{dx} & =\lim_{\Delta x\to0}\frac{\Delta y}{\Delta x}\\ & =\lim_{\Delta x\to0}\left[\frac{1}{x}\ln\left(1+\frac{\Delta x}{x}\right)^{\frac{x}{\Delta x}}\right]\\ & =\frac{1}{x}\lim_{\Delta x\to0}\left[\ln\left(1+\frac{\Delta x}{x}\right)^{\frac{x}{\Delta x}}\right]\\ & =\frac{1}{x}\ln\left[\lim_{\Delta x\to0}\left(1+\frac{\Delta x}{x}\right)^{\frac{x}{\Delta x}}\right]\\ & =\frac{1}{x}\ln e\\ & =\frac{1}{x}.\end{align}\]
[Note than when \(\Delta x\to0\), \(\frac{\Delta x}{x}\to0\). Therefore, \({\displaystyle \lim_{\Delta x\to0}\left(1+\frac{\Delta x}{x}\right)^{\frac{x}{\Delta x}}=e}\) from placing \(u=\frac{\Delta x}{x}\) in \({\displaystyle \lim_{u\to0}(1+u)^{1/u}=e}\)
(see here)].


 

Hence
\[\bbox[#F2F2F2,5px,border:2px solid black]{\frac{d}{dx}\ln x=\frac{1}{x},\qquad(x>0).\tag{a}}\]

Now consider \(y=\log_{a}x\). What is \(dy/dx\)?

We write \[y=\log_{a}x=\frac{\ln x}{\ln a}.\] Therefore
\[\begin{align} \frac{dy}{dx} & =\frac{1}{\ln a}\frac{d}{dx}\ln x\\ & =\frac{1}{\ln a}\frac{1}{x}.\end{align}\]
\[\bbox[#F2F2F2,5px,border:2px solid black]{\frac{d}{dx}\log_{a}x=\frac{1}{x\ln a},\qquad(x>0).\tag{b}}\]

  • If \(u(x)>0\) is a differentiable function, applying the chain rule to (a) produces: \[\dfrac{d}{dx}\ln u=\frac{1}{u}\frac{du}{dx}\]
  • When possible, to differentiate a function involving logarithms, first use the properties of logarithms to convert products to sums, quotients to differences and exponents to constant multiples then differentiate the result.
Example 1

Find the equation of the tangent line to the curve of \(y=\ln(x^{2}+1)\) when \(x=0\).

Solution

The slope of the tangent is \(dy/dx\)
\[\begin{align} \frac{dy}{dx} & =\frac{d}{dx}\ln(\overbrace{x^{2}+1}^{u})\\ & =\frac{1}{u}\frac{du}{dx}\\ & =\frac{1}{x^{2}+1}(2x)\\ & =\frac{2x}{x^{2}+1}\end{align}\]
The slope of the tangent \(m_{\text{tan}}\) when \(x=0\) is obtained by substituting 0 for \(x\) in the above equation: \[m_{\text{tan}}=\left.\frac{2x}{x^{2}+1}\right|_{x=0}=0\] Because when \(x=0\), \(y=\ln(0+1)=0\), the horizontal line \(y=0\) is tangent to the graph of \(y=\ln(x^{2}+1)\) at the origin. The graph of \(y=\ln(x^{2}+1)\) is shown below.

Fig 1: The tangent line to the graph of $y=\ln\left(1+x^2\right)$ at $(0,0)$ is horizontal.
Example 2

Find \(\dfrac{d}{dx}\left[\ln\dfrac{\sqrt{x+1}(2+\cos x)}{x^{2}}\right]\)

Solution

\[\begin{align} \dfrac{d}{dx}\left[\ln\dfrac{\sqrt{x+1}(2+\cos x)}{x^{2}}\right] & =\dfrac{d}{dx}\left[\ln\sqrt{x+1}+\ln(2+\cos x)-\ln x^{2}\right]\\ & =\dfrac{d}{dx}\left[\frac{1}{2}\ln(x+1)+\ln(2+\cos x)-2\ln x\right]\\ & =\frac{1}{2(x+1)}+\frac{1}{2+\cos x}\left(\dfrac{d}{dx}\cos x\right)-\frac{2}{x}\\ & =\frac{1}{2(x+1)}-\frac{\sin x}{2+\cos x}-\frac{2}{x}\\\end{align}\]

Now an important example:

Example 3

Find \(\dfrac{d}{dx}\ln|x|\).

Solution

We consider two cases:

(a) \(x>0\). Then \(|x|=x\) and \[\dfrac{d}{dx}\ln|x|=\dfrac{d}{dx}\ln x=\frac{1}{x}.\] (b) \(x<0\). Then \(|x|=-x\) and
\[\dfrac{d}{dx}\ln|x|=\dfrac{d}{dx}\ln(-x)=\frac{1}{-x}\frac{d}{dx}(-x)=\frac{1}{-x}(-1)=\frac{1}{x}.\]
Because we get the same results in both cases, we conclude
\[\frac{d}{dx}\ln|x|=\frac{1}{x}.\]

From the above example, we conclude

\[\bbox[#F2F2F2,5px,border:2px solid black]{\frac{d}{dx}\ln|x|=\frac{1}{x},\tag{c}}\]

More generally, if $u$ is a differentiable function of $x$ using the chain rule we have

\[\bbox[#F2F2F2,5px,border:2px solid black]{\frac{d}{dx}\ln|u|=\frac{1}{u}\frac{du}{dx}.\tag{d}}\]

 

Example 4

Find \(\dfrac{d}{dx}\ln|\cos x|\).

Solution

Let \(u=\cos x\). Then \(\dfrac{d}{dx}\ln|\cos x|=\dfrac{d}{dx}\ln|u|\) and it follows from Equation (d) that

\[\begin{align} \dfrac{d}{dx}\ln|\cos x| & =\frac{1}{u}\frac{du}{dx}\\ & =\frac{1}{\cos x}(-\sin x)\\ & =-\tan x.\end{align}\]

Logarithmic Differentiation

To differentiate a function \(y=f(x)\) with respect to \(x\) and \(f\) composed of products, quotients, and exponents, it is sometimes easier to:

  1. Take the natural logarithms of both sides of \(y=f(x)\): \[\ln y=\ln f(x).\]
  2. Expand the right side using the properties of logarithms.
  3. Take the derivatives of both sides.
  4. Isolate \(dy/dx\) and replace \(y\) by \(f(x)\).

Notice that if \(f(x)<0\) for some \(x\), then \(\ln f(x)\) is not defined for those values of \(x\). So to use logarithmic differentiation, we should technically start with $|y|=\left|f(x)\right|$, and then take the natural logarithm and derivative of each side. However, because the derivative of $\ln |u|$  is the same as the derivative of $\ln u$ (when $u>0$), we can ignore the fact the $\ln u$ is not defined for $u\leq 0$. 

Example 5

Find \(y’\) given
\[y=\frac{x\sin x}{(2-x)\sqrt{1+x^{4}}}\]

Solution

This would be really messy to differentiate $y$ directly. Instead we can use logarithmic differentiation.

First we take the natural logarithm of both sides and exapnd the right hand side using the properties of logarithms:
\[\begin{align} \ln y & =\ln\frac{x\sin x}{(2-x)\sqrt{1+x^{4}}}\\ & =\ln x+\ln\sin x-\ln(2-x)-\frac{1}{2}\ln(1+x^{4}).\end{align}\]
Now we can differentiate both sides:
\[\begin{align} \frac{1}{y}y’ & =\frac{1}{x}+\frac{1}{\sin x}\left(\frac{d}{dx}\sin x\right)\\ & \hspace{1em}-\frac{1}{2-x}\left(\frac{d}{dx}(2-x)\right)-\frac{1}{2(1+x^{4})}\frac{d}{dx}(1+x^{4})\end{align}\]
or
\[\frac{y’}{y}=\frac{1}{x}+\frac{\cos x}{\sin x}-\frac{(-1)}{2-x}-\frac{4x^{3}}{2(1+x^{4})}\]
Multiplying both sides by \(y\):
\[\begin{align} y’ & =y\left[\frac{1}{x}+\frac{\cos x}{\sin x}+\frac{1}{2-x}-\frac{2x^{3}}{1+x^{4}}\right]\\ & =\frac{x\sin x}{(2-x)\sqrt{1+x^{4}}}\left[\frac{1}{x}+\frac{\cos x}{\sin x}+\frac{1}{2-x}-\frac{2x^{3}}{1+x^{4}}\right]\end{align}\]
We have found the solution, but we may want to simplify it further:
\[\begin{align} y’ & =\frac{\sin x}{(2-x)\sqrt{1+x^{4}}}+\frac{x\cos x}{(2-x)\sqrt{1+x^{4}}}\\ & \qquad+\frac{x\sin x}{(2-x)^{2}\sqrt{1+x^{4}}}-\frac{2x^{4}\sin x}{(2-x)\sqrt{(1+x^{4})^{3}}}\\ & =\frac{\sin x+x\cos x}{(2-x)\sqrt{1+x^{4}}}+\frac{x\sin x}{(2-x)^{2}\sqrt{1+x^{4}}}\\ & \qquad-\frac{2x^{4}\sin x}{(2-x)\sqrt{(1+x^{4})^{3}}}\end{align}\]

  • In the this example, $y4 can be negative for some values of $x$ . To be more accurate, we first have to take the absolute value of both sides and then take the natural logarithms, namely \[

    \ln|y|=\ln|x|+\ln|\sin x|-\ln|2-x|-\frac{1}{4}\ln|1+x^{4}|.\]
    Because the derivative $\ln u$ (when $u>0$ ) is the same as the derivative of $\ln |u|$, the derivative of each term in the above equation is the same as the derivative of each term without the absolute value symbols. Therefore, the final result is correct for every x in the domain of the function. You may verify it by differentiating the original function using regular differentiation rules. 

 

  The Power Rule 

Previously, we proved that the power rule \[ \bbox[#F2F2F2,5px,border:2px solid black]{\frac{d}{dx}x^r=r x^{r-1}}\] holds for rational exponents. Now we can prove that the power rule is also correct if $r$ is any real number (rational or irrational). 

 

Show the proof

Let $y=x^r$ , where $r$ is a real number. Then \[|y|=\left|x^{r}\right|=|x|^{r}.\]
Taking the natural logarithm of both sides gives \[\ln|y|=\ln|x|^{r}=r\ln|x|\qquad(x\neq0)\]
Differentiating both sides: \[\frac{y’}{y}=r\frac{1}{x}.\] Therefore \[

\[y’=r\frac{y}{x}=r\frac{x^{r}}{x}=rx^{r-1}.\]
If $x=0$, we can use the definition of a derivative to show that $f'( 0 ) =0$ for $r \geq  1$.