Logarithmic differentiation is a method for finding a derivative in which we first take the logarithm of both sides of an equation. Why is this extra step useful? It allows us to turn a product into a sum, a quotient into a difference, and bring an exponent down in front of the logarithm.
As a result, the complex structure of a function becomes much easier to differentiate. This method is especially useful when the variable appears both in the base and in the exponent. It is also convenient for functions that contain products, fractions, and powers. First, let us look at the main formula, and then we will see how to apply it to specific functions.
Logarithmic Differentiation: Main Formula
Consider the function \( y=f(x) \). First, assume that \( f(x)>0 \) on the interval we are interested in. Under this condition, we can apply the natural logarithm to both sides of the equation:
\[
\ln\bigl(y\bigr)=\ln\bigl(f(x)\bigr).
\]
Next, differentiate both sides of the equation with respect to \( x \). It is important to remember that \( y \) depends on \( x \). Therefore, when differentiating \( \ln\bigl(y\bigr) \), we use the chain rule:
\[
\frac{d}{dx}\left(\ln\bigl(y\bigr)\right)=\frac{1}{y}\cdot\frac{dy}{dx}.
\]
The right-hand side of the equation also depends on \( x \). So,
\[
\frac{1}{y}\cdot\frac{dy}{dx}=\frac{d}{dx}\left(\ln\bigl(f(x)\bigr)\right).
\]
Now multiply both sides of the equation by \( y \):
\[
\frac{dy}{dx}=y\cdot\frac{d}{dx}\left(\ln\bigl(f(x)\bigr)\right).
\]
Since \( y=f(x) \), we get the main formula of logarithmic differentiation:
\[
\frac{dy}{dx}=f(x)\cdot\frac{d}{dx}\left(\ln\bigl(f(x)\bigr)\right).
\]
This formula is the result of consistently taking the logarithm and then differentiating the equation. So it should not be seen as a separate rule that must be applied mechanically. It is important to understand where it comes from and what role the logarithm plays in it.
If the function can take negative values but is not equal to zero, we use the logarithm of the absolute value:
\[
\ln\bigl(|y|\bigr)=\ln\bigl(|f(x)|\bigr).
\]
Since
\[
\frac{d}{dx}\left(\ln\bigl(|y|\bigr)\right)=\frac{1}{y}\cdot\frac{dy}{dx},
\]
on every interval where \( f(x)\ne0 \), we have
\[
\frac{1}{y}\cdot\frac{dy}{dx}=\frac{d}{dx}\left(\ln\bigl(|f(x)|\bigr)\right).
\]
After multiplying both sides of the equation by \( y=f(x) \), we get
\[
\frac{dy}{dx}=f(x)\cdot\frac{d}{dx}\left(\ln\bigl(|f(x)|\bigr)\right).
\]
This formula is valid on intervals where the function is defined and is not equal to zero. Therefore, the logarithm of the absolute value allows us to work not only with positive values of the function.
Logarithm Properties: Simplifying Complex Functions
At first glance, it may seem that the logarithm adds an extra step. However, it is exactly this step that changes the structure of the function and makes it easier to differentiate. Why does this happen? The reason lies in the properties of logarithms.
The logarithm of a product turns multiplication into addition. If \( u(x)>0 \) and \( v(x)>0 \), then
\[
\ln\bigl(u(x)\cdot v(x)\bigr)=\ln\bigl(u(x)\bigr)+\ln\bigl(v(x)\bigr).
\]
The logarithm of a quotient turns division into subtraction. Under the conditions \( u(x)>0 \) and \( v(x)>0 \), we have
\[
\ln\left(\frac{u(x)}{v(x)}\right)=\ln\bigl(u(x)\bigr)-\ln\bigl(v(x)\bigr).
\]
In addition, the exponent can be brought down in front of the logarithm. If \( u(x)>0 \), then
\[
\ln\bigl(u(x)^{v(x)}\bigr)=v(x)\cdot\ln\bigl(u(x)\bigr).
\]
The last property is especially important for functions in which the exponent depends on \( x \). After taking the logarithm, this power expression turns into a product. Then it can be differentiated using the usual product rule.
Let us consider the general case:
\[
y=f(x)=u(x)^{\alpha(x)}\cdot v(x)^{\beta(x)},
\]
where \( u(x)>0 \) and \( v(x)>0 \). After taking the logarithm, we get
\[
\ln\bigl(f(x)\bigr)=\alpha(x)\cdot\ln\bigl(u(x)\bigr)+\beta(x)\cdot\ln\bigl(v(x)\bigr).
\]
Now substitute the original function and the expression obtained after taking the logarithm into the main formula:
\[
\frac{dy}{dx}=u(x)^{\alpha(x)}\cdot v(x)^{\beta(x)}\cdot\frac{d}{dx}\left(\alpha(x)\cdot\ln\bigl(u(x)\bigr)+\beta(x)\cdot\ln\bigl(v(x)\bigr)\right).
\]
So, a complex product of powers turns into a sum of simpler expressions inside the differentiation expression. In this form, the function becomes much more convenient to differentiate.
Logarithmic Differentiation: Examples of Finding Derivatives
Let us look at how the formula we obtained can be applied to functions of different types. The examples will gradually become more complex: from a power with a variable exponent to expressions that contain products, fractions, and several powers.
Example 1. Find the derivative of the function \( y=x^x \) (\( x>0 \))
In this function, the variable \( x \) appears both in the base and in the exponent. The usual power rule \( (x^n)’=n\cdot x^{n-1} \) cannot be applied directly here, because it assumes that the exponent \( n \) is constant.
Let \( f(x)=x^x \). Take the logarithm of the function and use the logarithm property for powers:
\[
\ln\bigl(f(x)\bigr)=\ln\bigl(x^x\bigr)=x\cdot\ln\bigl(x\bigr).
\]
By the main formula of logarithmic differentiation, we have
\[
\frac{dy}{dx}=f(x)\cdot\frac{d}{dx}\left(\ln\bigl(f(x)\bigr)\right).
\]
Substitute the original function and the expression obtained after taking the logarithm:
\[
\frac{dy}{dx}=x^x\cdot\frac{d}{dx}\left(x\cdot\ln\bigl(x\bigr)\right).
\]
The expression \( x\cdot\ln\bigl(x\bigr) \) is a product of two functions. By the product rule, we first multiply the derivative of the first factor by the second factor, and then add the product of the first factor and the derivative of the second:
\[
\left(x\cdot\ln\bigl(x\bigr)\right)’=x’\cdot\ln\bigl(x\bigr)+x\cdot\left(\ln\bigl(x\bigr)\right)’.
\]
Since \( x’=1 \), and \( \left(\ln\bigl(x\bigr)\right)’=\dfrac{1}{x} \), we get
\[
\left(x\cdot\ln\bigl(x\bigr)\right)’=1\cdot\ln\bigl(x\bigr)+x\cdot\frac{1}{x}.
\]
After simplifying, we have
\[
\left(x\cdot\ln\bigl(x\bigr)\right)’=\ln\bigl(x\bigr)+1.
\]
Therefore, the final answer is
\[
\frac{dy}{dx}=x^x\cdot\left(\ln\bigl(x\bigr)+1\right).
\]
Example 2. Find the derivative of the function \( y=\bigl(x^2+1\bigr)^x \)
The base of the power, \( x^2+1 \), depends on \( x \), and the exponent is also a variable quantity. Since \( x^2+1>0 \) for all real \( x \), the natural logarithm of the function is defined on the entire real line.
Let \( f(x)=\bigl(x^2+1\bigr)^x \). After taking the logarithm, we have
\[
\ln\bigl(f(x)\bigr)=\ln\left(\bigl(x^2+1\bigr)^x\right)=x\cdot\ln\bigl(x^2+1\bigr).
\]
Substitute the original function and the obtained expression into the main formula:
\[
\frac{dy}{dx}=\bigl(x^2+1\bigr)^x\cdot\frac{d}{dx}\left(x\cdot\ln\bigl(x^2+1\bigr)\right).
\]
The expression in parentheses is a product of the functions \( x \) and \( \ln\bigl(x^2+1\bigr) \). Therefore,
\[
\left(x\cdot\ln\bigl(x^2+1\bigr)\right)’=x’\cdot\ln\bigl(x^2+1\bigr)+x\cdot\left(\ln\bigl(x^2+1\bigr)\right)’.
\]
The function \( \ln\bigl(x^2+1\bigr) \) is a composite function. The outer function is the logarithm, and the inner function is \( x^2+1 \). By the chain rule,
\[
\left(\ln\bigl(x^2+1\bigr)\right)’=\frac{1}{x^2+1}\cdot\left(x^2+1\right)’.
\]
Since \( \left(x^2+1\right)’=2\cdot x \), we have
\[
\left(\ln\bigl(x^2+1\bigr)\right)’=\frac{2\cdot x}{x^2+1}.
\]
Substitute the found derivatives into the product rule:
\[
\left(x\cdot\ln\bigl(x^2+1\bigr)\right)’=1\cdot\ln\bigl(x^2+1\bigr)+x\cdot\frac{2\cdot x}{x^2+1}.
\]
After simplifying, we get
\[
\left(x\cdot\ln\bigl(x^2+1\bigr)\right)’=\ln\bigl(x^2+1\bigr)+\frac{2\cdot x^2}{x^2+1}.
\]
Therefore, the derivative of the function is
\[
\frac{dy}{dx}=\bigl(x^2+1\bigr)^x\cdot\left(\ln\bigl(x^2+1\bigr)+\frac{2\cdot x^2}{x^2+1}\right).
\]
Example 3. Find the derivative of the function \( y=x^{\sin(x)} \) (\( x>0 \))
Here the base of the power is \( x \), and the exponent is the function \( \sin(x) \). Both parts of the power expression depend on \( x \).
Let \( f(x)=x^{\sin(x)} \). Take the logarithm of the function:
\[
\ln\bigl(f(x)\bigr)=\ln\left(x^{\sin(x)}\right)=\sin(x)\cdot\ln\bigl(x\bigr).
\]
Substitute the obtained expression into the main formula:
\[
\frac{dy}{dx}=x^{\sin(x)}\cdot\frac{d}{dx}\left(\sin(x)\cdot\ln\bigl(x\bigr)\right).
\]
Inside the derivative, we have a product of the functions \( \sin(x) \) and \( \ln\bigl(x\bigr) \). Therefore,
\[
\left(\sin(x)\cdot\ln\bigl(x\bigr)\right)’=\left(\sin(x)\right)’\cdot\ln\bigl(x\bigr)+\sin(x)\cdot\left(\ln\bigl(x\bigr)\right)’.
\]
Since \( \left(\sin(x)\right)’=\cos(x) \), and \( \left(\ln\bigl(x\bigr)\right)’=\dfrac{1}{x} \), we get
\[
\left(\sin(x)\cdot\ln\bigl(x\bigr)\right)’=\cos(x)\cdot\ln\bigl(x\bigr)+\sin(x)\cdot\frac{1}{x}.
\]
So,
\[
\left(\sin(x)\cdot\ln\bigl(x\bigr)\right)’=\cos(x)\cdot\ln\bigl(x\bigr)+\frac{\sin(x)}{x}.
\]
Substitute the derivative we found. Therefore, finally we have:
\[
\frac{dy}{dx}=x^{\sin(x)}\cdot\left(\cos(x)\cdot\ln\bigl(x\bigr)+\frac{\sin(x)}{x}\right).
\]
Example 4. Find the derivative of the function \( y=\frac{\bigl(x^2+1\bigr)^3\cdot\sqrt{x-1}}{x^4} \) (\( x>1 \))
The function contains a product, a quotient, and several powers. It can be differentiated using the usual rules, but the calculations would be quite bulky. Taking the logarithm allows us to turn the product into a sum and the quotient into a difference.
Let
\[
f(x)=\frac{\bigl(x^2+1\bigr)^3\cdot\sqrt{x-1}}{x^4}.
\]
Take the logarithm of the function:
\[
\ln\bigl(f(x)\bigr)=\ln\left(\frac{\bigl(x^2+1\bigr)^3\cdot\sqrt{x-1}}{x^4}\right).
\]
Apply the logarithm properties for a product and a quotient:
\[
\ln\bigl(f(x)\bigr)=\ln\left(\bigl(x^2+1\bigr)^3\right)+\ln\bigl(\sqrt{x-1}\bigr)-\ln\bigl(x^4\bigr).
\]
Since \( \sqrt{x-1}=\bigl(x-1\bigr)^{\frac{1}{2}} \), the exponents can be brought down in front of the logarithms:
\[
\ln\bigl(f(x)\bigr)=3\cdot\ln\bigl(x^2+1\bigr)+\frac{1}{2}\cdot\ln\bigl(x-1\bigr)-4\cdot\ln\bigl(x\bigr).
\]
Substitute the original function and the obtained expression into the main formula:
\[
\frac{dy}{dx}=\frac{\bigl(x^2+1\bigr)^3\cdot\sqrt{x-1}}{x^4}\cdot\frac{d}{dx}\left(3\cdot\ln\bigl(x^2+1\bigr)+\frac{1}{2}\cdot\ln\bigl(x-1\bigr)-4\cdot\ln\bigl(x\bigr)\right).
\]
After taking the logarithm, the complex product and quotient turned into a sum and a difference. Therefore, we differentiate each term separately.
For the first term, use the rule for the derivative of a constant multiplied by a function and the chain rule:
\[
\left(3\cdot\ln\bigl(x^2+1\bigr)\right)’=3\cdot\left(\ln\bigl(x^2+1\bigr)\right)’.
\]
Next, we have
\[
\left(3\cdot\ln\bigl(x^2+1\bigr)\right)’=3\cdot\frac{1}{x^2+1}\cdot\left(x^2+1\right)’.
\]
Since \( \left(x^2+1\right)’=2\cdot x \), we get
\[
\left(3\cdot\ln\bigl(x^2+1\bigr)\right)’=\frac{6\cdot x}{x^2+1}.
\]
Similarly, find the derivative of the second term:
\[
\left(\frac{1}{2}\cdot\ln\bigl(x-1\bigr)\right)’=\frac{1}{2}\cdot\frac{1}{x-1}\cdot\left(x-1\right)’.
\]
Since \( \left(x-1\right)’=1 \), we have
\[
\left(\frac{1}{2}\cdot\ln\bigl(x-1\bigr)\right)’=\frac{1}{2\cdot(x-1)}.
\]
For the last term, we get
\[
\left(-4\cdot\ln\bigl(x\bigr)\right)’=-4\cdot\frac{1}{x}=-\frac{4}{x}.
\]
Therefore, the derivative of the expression obtained after taking the logarithm is
\[
\frac{6\cdot x}{x^2+1}+\frac{1}{2\cdot(x-1)}-\frac{4}{x}.
\]
Substitute this result into the main formula, and we get the final answer:
\[
\frac{dy}{dx}=\frac{\bigl(x^2+1\bigr)^3\cdot\sqrt{x-1}}{x^4}\cdot\left(\frac{6\cdot x}{x^2+1}+\frac{1}{2\cdot(x-1)}-\frac{4}{x}\right).
\]
Example 5. Find the derivative of the function \( y=\left(\frac{x+1}{x-1}\right)^{x^2} \) (\( x>1 \))
In this function, the base is a quotient of two expressions, and the exponent also depends on \( x \). Taking the logarithm allows us to work separately with the exponent and with the quotient in the base.
Let
\[
f(x)=\left(\frac{x+1}{x-1}\right)^{x^2}.
\]
Take the logarithm of the function:
\[
\ln\bigl(f(x)\bigr)=\ln\left(\left(\frac{x+1}{x-1}\right)^{x^2}\right).
\]
Bring the exponent down in front of the logarithm:
\[
\ln\bigl(f(x)\bigr)=x^2\cdot\ln\left(\frac{x+1}{x-1}\right).
\]
Now apply the logarithm property for a quotient:
\[
\ln\bigl(f(x)\bigr)=x^2\cdot\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right).
\]
Substitute the obtained expression into the main formula:
\[
\frac{dy}{dx}=\left(\frac{x+1}{x-1}\right)^{x^2}\cdot\frac{d}{dx}\left(x^2\cdot\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right)\right).
\]
Inside the derivative, we have a product. The first factor is \( x^2 \), and the second is the difference of logarithms. By the product rule,
\[
\left(x^2\cdot\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right)\right)’=\left(x^2\right)’\cdot\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right)+x^2\cdot\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right)’.
\]
We find the derivative of the difference term by term. Both logarithms are composite functions:
\[
\begin{gathered}
\left(\ln\bigl(x+1\bigr)\right)’=\dfrac{1}{x+1}\cdot\left(x+1\right)’=\dfrac{1}{x+1},\\[4pt]
\left(\ln\bigl(x-1\bigr)\right)’=\dfrac{1}{x-1}\cdot\left(x-1\right)’=\dfrac{1}{x-1}.
\end{gathered}
\]
Therefore,
\[
\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right)’=\frac{1}{x+1}-\frac{1}{x-1}.
\]
Since \( \left(x^2\right)’=2\cdot x \), after substitution we get
\[
\left(x^2\cdot\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right)\right)’=2\cdot x\cdot\left(\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)\right)+x^2\cdot\left(\frac{1}{x+1}-\frac{1}{x-1}\right).
\]
The difference of logarithms can be combined again:
\[
\ln\bigl(x+1\bigr)-\ln\bigl(x-1\bigr)=\ln\left(\frac{x+1}{x-1}\right).
\]
Now simplify the difference of fractions. Bring them to a common denominator:
\[
\frac{1}{x+1}-\frac{1}{x-1}=\frac{x-1-(x+1)}{(x+1)\cdot(x-1)}.
\]
In the numerator, we have \( x-1-x-1=-2 \), and in the denominator, \( (x+1)\cdot(x-1)=x^2-1 \). Therefore,
\[
\frac{1}{x+1}-\frac{1}{x-1}=-\frac{2}{x^2-1}.
\]
So, the derivative of the expression obtained after taking the logarithm is
\[
2\cdot x\cdot\ln\left(\frac{x+1}{x-1}\right)-\frac{2\cdot x^2}{x^2-1}.
\]
Substitute the found result into the main formula, and we get the final answer:
\[
\frac{dy}{dx}=\left(\frac{x+1}{x-1}\right)^{x^2}\cdot\left(2\cdot x\cdot\ln\left(\frac{x+1}{x-1}\right)-\frac{2\cdot x^2}{x^2-1}\right).
\]
Next Steps in Differentiation: Topics for Further Study
After logarithmic differentiation, it is worth looking separately at the derivatives of the functions on which this method is based. The following topics will help you better understand the rules used here and see how they work in different types of problems.
- Derivative of a Power Function: Formula, Derivation, Examples — In this article, we will discuss the main formula, explain where it comes from, and apply it when finding derivatives of power functions.
- Derivative of an Exponential Function: Formula, Derivation, Examples — This article will show how to differentiate exponential functions, why the logarithm of the base appears, and how to solve typical examples.
- Derivative of the Natural Logarithm: Formula, Derivation, Examples — We will consider the derivation of the formula, the conditions for using it, and examples of finding derivatives of simple and composite logarithmic functions.
Logarithmic Differentiation: From Formula to Programming Algorithm
If you are interested in programming, try going one step further: not only find the derivative by hand, but also implement this process in code. The flowchart below shows a simple algorithm for calculating the value of the function \( x^x \) and its derivative found using logarithmic differentiation. It can be used as a basis for a program in Pascal, Python, C++, JavaScript, or any other language you are comfortable working with.
