Let’s consider the function y=\ln|x|. How do we calculate its derivative?


First of all we observe that the function is defined for every real value x\neq 0.

Let’s see what happens separately on the two sets (-\infty,0) and (0,+\infty).


  1. For x >0. In this case, using the definition of modulus we have |x|=x, and the function is written as:

    y= \ln x,\qquad \text{$x\in (0,+\infty)$.}

    Its derivative is therefore already known from the table of derivatives, and is \frac{d}{dx} \ln x = \frac{1}{x}.

  1. For x. When x is negative, using the definition of modulus we have |x|=-x.
    So

    y= \ln(-x),\qquad \text{ $x\in (-\infty,0)$,}


    where -x is a positive number. We can then read the function as a composition

    x\longmapsto -x\longmapsto \ln(-x),


    and calculate its derivative with the Chain rule:

    \frac{d}{dx} \ln(-x) = \underbrace{\frac{1}{-x}}_{A} \cdot \underbrace{(-1)}_{B} = \frac{1}{x},


    where the term A is the derivative of the external function (the logarithm on the half-line (0,+\infty)) computed in the internal function -x, and the term B is the derivative of the internal function, computed in x.

Conclusion

We have found that the derivative is \frac{1}{x} for both x > 0 and x < 0.

We can then write a unique formula for the derivative:

\boxed{ \frac{d}{dx} \ln|x| = \frac{1}{x}\qquad \forall x\neq 0. }

Derivative of \ln|g(x)|


Let’s consider the function y=\ln|g(x)| where g is a given function.

Using the result just obtained we can show that, if g is differentiable, the function y=\ln|g(x)| is also differentiable, and its derivative is

\boxed{ \frac{d}{dx} \ln|g(x)| = \frac{g'(x)}{g(x)} }


at every x such that g(x)\neq 0.

In fact, by viewing the function as a composition

x\overset{g}\longmapsto g(x)\overset{\ln|\cdot|}{\longmapsto} \ln|g(x)|,


we can apply the Chain Rule: we thus obtain

\frac{d}{dx} \ln|g(x)|= \underbrace{\frac{1}{g(x)}}_{A} \cdot \underbrace{g'(x)}_{B} = \frac{g'(x)}{g(x)},


where A is the derivative of the external function \ln|\cdot|, computed at g(x), while B is the derivative of the internal function g, computed at x.

Example

Let’s calculate the derivative of y=\ln|1-x^2|.

Using the rule just seen with g(x)=1-x^2 we have

\frac{d}{dx} \ln|1-x^2| = \frac{1}{1-x^2} \cdot (-2x) = \frac{-2x}{1-x^2}


for each value x\in(-\infty,-1)\cup(-1,1)\cup(1,+\infty).