Why Absolute Values Appear Inside Natural Logarithms
The natural logarithm \(\ln y\) is defined for positive real inputs \(y\). That restriction can make \(\ln(u(x))\) unsuitable when \(u(x)\) is negative at some points. The expression \(\ln|u(x)|\), however, is defined at every point where \(u(x)\ne 0\), because the absolute value is then positive.
This makes \(\ln|u(x)|\) useful when an inner function can be either positive or negative. Its derivative has a compact form, but the domain condition matters: at any point where \(u(x)=0\), the logarithm is undefined, and the derivative formula cannot be used there.
The denominator is \(u(x)\), not \(|u(x)|\). The sign of \(u(x)\) is retained in the derivative. We will derive this carefully and see why the same formula holds on both sides of a sign change, while never applying at the zero itself.
Deriving the Formula
The key fact is that a differentiable function that is nonzero at a point keeps the same sign in a sufficiently small interval around that point. Thus, locally, there are two cases. If \(u\) is positive, then \(\ln|u|=\ln u\). If \(u\) is negative, then \(|u|=-u\), so \(\ln|u|=\ln(-u)\). The chain rule for natural logarithms gives a derivative in either case.
In a neighborhood where \(u\) remains positive, \(\ln|u(x)|=\ln(u(x))\). The chain rule gives derivative \(u'(x)/u(x)\).
In a neighborhood where \(u\) remains negative, \(\ln|u(x)|=\ln(-u(x))\). Apply the chain rule to the inner function \(-u(x)\).
The derivative is \((-u'(x))/(-u(x))\), which equals \(u'(x)/u(x)\). Therefore the same formula applies for either sign, provided \(u(x)\ne 0\).
For completeness, in the negative case the numerator and denominator both acquire a minus sign. They cancel, but the final denominator is still the signed value \(u(x)\), not its absolute value.
Worked Examples
Worked Example: A Sign-Changing Quadratic
Differentiate \(f(x)=\ln|x^2-4|\), and state where the result is valid.
Set \(u(x)=x^2-4\). Then \(u'(x)=2x\). The logarithm is defined when \(x^2-4\ne 0\), which means \(x\ne -2\) and \(x\ne 2\). Apply the formula on this domain:
The inner function is negative for \(-2<x<2\) and positive for \(x<-2\) or \(x>2\). The formula holds on all three intervals; the two roots are excluded because \(f\) is undefined there.
Check the negative-input region at \(x=0\). Here \(u(0)=-4\), so \(f(0)=\ln 4\), and the formula gives \(f'(0)=0/(-4)=0\). Locally, \(|x^2-4|=4-x^2\), whose logarithm has derivative \((-2x)/(4-x^2)\), also \(0\) at \(x=0\). The two computations agree.
Worked Example: A Linear Inner Function That Changes Sign
Differentiate \(g(x)=\ln|3-2x|\), and check the derivative on both sides of its zero.
Let \(u(x)=3-2x\), so \(u'(x)=-2\). The inner function is zero at \(x=3/2\), so \(g\) is defined only when \(x\ne 3/2\). Therefore
For \(x=1/2\), the inner value is \(3-2(1/2)=2\), and the formula gives \(-2/2=-1\). On this positive-input region, \(g(x)=\ln(3-2x)\), whose chain-rule derivative is also \(-2/(3-2x)=-1\) at \(x=1/2\).
For \(x=2\), the inner value is \(3-4=-1\), and the formula gives \(-2/(-1)=2\). Here the inner function is negative. Locally, \(|3-2x|=2x-3\), so \(g(x)=\ln(2x-3)\) and its derivative at \(x=2\) is \(2/(4-3)=2\). The check confirms the formula on both sides, while \(x=3/2\) remains excluded.
Worked Example: A Trigonometric Inner Function
Differentiate \(h(x)=\ln|\sin x|\), and evaluate the derivative at \(x=-\pi/6\).
Take \(u(x)=\sin x\), so \(u'(x)=\cos x\). The expression is defined wherever \(\sin x\ne 0\), or equivalently wherever \(x\) is not an integer multiple of \(\pi\). Thus
At \(x=-\pi/6\), \(\sin(-\pi/6)=-1/2\) and \(\cos(-\pi/6)=\sqrt{3}/2\). The inner function is negative, but it is nonzero, so the formula applies:
As a direct check, near \(-\pi/6\) the sine remains negative, so \(h(x)=\ln(-\sin x)\). Differentiating locally gives \((-\cos x)/(-\sin x)=\cos x/\sin x\), which has the same value \(-\sqrt{3}\).
Sign Changes and the Domain
A continuous inner function can change sign only by passing through zero. For \(\ln|u(x)|\), each such zero is a point where the function is undefined. The domain is therefore split into intervals on which \(u\) has a fixed sign, and the derivative formula applies on each interval. The formula does not fill in the missing points or make the logarithm differentiable there.
For example, \(\ln|x|\) has domain \(x\ne 0\). Its derivative is \(1/x\) on the two intervals \(x<0\) and \(x>0\). Although the same formula works on both intervals, there is no value or derivative at \(x=0\). When differentiating a specific expression, first identify where its inner function is zero, then state the derivative only on the remaining domain.
A Common Sign Error
A frequent mistake is to replace the signed denominator by its absolute value. For instance, an incorrect calculation for \(q(x)=\ln|x|\) is
This fails at negative inputs. At \(x=-2\), the incorrect expression gives \(1/|-2|=1/2\). But near \(-2\), \(q(x)=\ln(-x)\), so its derivative is \(1/(-x)\), which equals \(-1/2\) at \(x=-2\). The correct general formula is
The absolute value belongs inside the logarithm to make its input positive. It does not replace the signed inner function in the derivative's denominator. A second error is to apply the formula at a zero of \(u\); at such a point \(\ln|u(x)|\) is undefined, so there is no derivative to calculate.
Why This Formula Is Useful
The formula extends the chain rule for natural logarithms to inner functions that may take negative values. It lets us differentiate one expression across every part of its domain without writing a separate final formula for each sign interval. The sign cases still explain why the formula works, and the domain restriction still has to be stated.
When checking work, ask three questions: Is the inner function differentiable at the point? Is it nonzero there? Did the final denominator retain its sign? If all three conditions are handled, \(\ln|u(x)|\) can be differentiated directly as \(u'(x)/u(x)\).
Check Your Understanding
For each question, pay attention to both the derivative and its domain.
- Differentiate \(\ln|x^2-9|\) and state the excluded inputs.
- On what domain is \(\ln|1-4x|\) defined, and what is its derivative there?
- Explain why the derivative of \(\ln|u(x)|\) has the same formula when \(u(x)<0\) as when \(u(x)>0\).
- What is the derivative of \(\ln|x|\) at \(x=-3\)? Why would \(1/|x|\) give an incorrect result?
- Can the formula \(u'(x)/u(x)\) be used where \(u(x)=0\)? Explain.