Logarithmic differentiation of y = f(x)
Type y = f(x), such as x^x or (x^2 + 1)^3 (x − 2)^4. The page takes ln of both sides, applies the logarithm laws, differentiates, and gives dy/dx = y · (y′/y).
- dy/dx
- x^x (1 + ln(x))
By logarithmic differentiation, the derivative of y = x^x is x^x (1 + ln(x)).
- ln y =
- x ln|x|
- y′/y =
- 1 + ln(x)
dy/dx: x^x (1 + ln(x)). By logarithmic differentiation, the derivative of y = x^x is x^x (1 + ln(x)).
How to calculate
Differentiates y = f(x) by taking ln of both sides: ln y, y′/y and dy/dx, checked numerically.
Example with the default inputs (y = f(x) x^x): By logarithmic differentiation, the derivative of y = x^x is x^x (1 + ln(x)).
Method: ln y = ln f(x), expanded by the logarithm laws, then y′/y = d/dx ln y and dy/dx = y · (y′/y). A computer algebra system differentiates; the answer is checked against a difference quotient.
- The variable is x; angles are in radians; ln is the natural logarithm.
- An answer that fails its check is not shown.
Worked examples
Each example is checked against the calculator on every build.
- y = f(x) (2x^4 + 1)^(tan(x)) gives y′/y = 8x^3 tan(x)/(1 + 2x^4) + ln(1 + 2x^4) sec(x)^2.Source: OpenStax, Calculus Volume 1, section 3.9 Derivatives of Exponential and Logarithmic Functions, Example 3.81. https://openstax.org/books/calculus-volume-1/pages/3-9-derivatives-of-exponential-and-logarithmic-functions
- y = f(x) x sqrt(2x + 1)/(e^x sin(x)^3) gives y′/y = 1/(1 + 2x) - 1 - 3 cos(x)/sin(x) + 1/x.
How it works
For y = f(x), logarithmic differentiation takes the natural logarithm of both sides, expands it with the logarithm laws, and differentiates:
ln|y| = ln|f(x)|, then y′/y = d/dx ln|f(x)|, so dy/dx = y · (y′/y)
The page expands ln y from the outside of f in:
- ln|u v| = ln|u| + ln|v| and ln|u/v| = ln|u| − ln|v|;
- ln|u^v| = v ln|u|, and ln(e^v) = v, ln(exp(v)) = v;
- ln|√u| = ln|u|/2;
- ln|−u| = ln|u|;
- any other part u stays as ln|u| (a number c as ln(c), without bars when it is positive; the constants e and π without bars).
A computer algebra system (nerdamer, open source) then differentiates ln y; the algebra runs in the background after you start typing. The page shows three things:
- ln y = the expanded logarithm, with bars.
- y′/y = its derivative, as the algebra writes it (without bars, since the derivative of ln|u| is u′/u, the same as that of ln u).
- dy/dx = y times y′/y, written as f, a space, and y′/y in brackets: x^x (1 + ln(x)). When f as written starts with a minus sign or has a + or − between terms anywhere (even inside brackets), f is put in brackets too: (x^2 + 1) (2x/(1 + x^2)).
Every answer is checked before it is shown. The derivative of ln y is compared with a numeric difference quotient at 20 points (to 1 part in a million). The expanded ln y is compared with ln|f(x)| at 18 test points (−33.1, −7.31, −3.17, −1.73, −0.91, −0.37, −0.043, 0.21, 0.57, 0.77, 1.33, 2.63, 3.37, 4.19, 8.93, 17.3, 41.3 and 97.7): at each point where both are real numbers they must agree to 1 part in 10⁹ of the larger size (at least 1), and there must be at least 3 such points. If a check fails, the algebra finds no formula, or the work takes over 3 seconds, the page says "No verified answer". A result that holds a number the algebra could only give rounded (a whole number past 2⁵³; a fraction p/q, p and q being the numbers that multiply its top and its bottom, such as 288557167/(342919925e), when q after removing its factors 2 and 5 is over 1,000,000, or is over 1 while |p| times it is over 10¹²; or a decimal with more than 12 significant digits) is not shown.
What you can type
- A number has at most 15 digits in a row. A computer number keeps only about 16 digits, so a longer one (9007199254740993) would stand for a nearby number (9007199254740992), and the page asks for fewer digits instead. Write very large or very small numbers with a power of ten (1e-20).
- y = f(x) uses the variable x. Numbers can have decimals (2.5) and powers of ten (1e-3).
- Operations: + − * / and ^ for powers. Brackets group. A number or bracket next to a letter multiplies: 2x, 3(x + 1), x sin(x).
- Constants: pi (or π) and e.
- Functions: sqrt, cbrt, ln (and log, the same natural logarithm), log10, exp, abs (or |x|), sin, cos, tan, sec, csc, cot, asin, acos, atan (arcsin, arccos, arctan also work), sinh, cosh, tanh and their inverses. Angles are in radians. sin x without brackets means sin(x); sin x^2 means sin(x²).
Worked examples by hand
y = (2x⁴ + 1)^tan(x) (OpenStax Calculus Volume 1, section 3.9, Example 3.81). ln y = tan(x) ln|2x⁴ + 1|. By the product rule, y′/y = sec²(x) ln(2x⁴ + 1) + tan(x) · 8x³/(2x⁴ + 1), which the page writes 8x^3 tan(x)/(1 + 2x^4) + ln(1 + 2x^4) sec(x)^2. So dy/dx = (2x⁴ + 1)^tan(x) (8x³ tan(x)/(1 + 2x⁴) + ln(1 + 2x⁴) sec²(x)).
y = x √(2x + 1)/(eˣ sin³x) (OpenStax Calculus Volume 1, section 3.9, Example 3.82). ln y = ln|x| + ln|2x + 1|/2 − x − 3 ln|sin(x)|. Differentiating term by term, y′/y = 1/x + 1/(2x + 1) − 1 − 3 cot(x), which the page writes 1/(1 + 2x) − 1 − 3 cos(x)/sin(x) + 1/x.
Other questions people ask
What is logarithmic differentiation?
A way to differentiate y = f(x) by first taking the natural logarithm of both sides. The logarithm laws turn products into sums, quotients into differences and powers into multiples, so ln y is easy to differentiate. Then y′/y = (ln y)′, and dy/dx = y · (ln y)′.
When should I use it?
When the variable is in both the base and the exponent, such as x^x or x^sin(x), where neither the power rule nor the exponential rule applies. It also saves work for long products and quotients, such as x √(2x + 1)/(eˣ sin³x).
What is the derivative of x^x?
ln y = x ln x. Differentiating, y′/y = ln x + 1 by the product rule. So dy/dx = x^x (1 + ln x).
Why do the logarithms have absolute values?
y can be negative, and ln is only defined for positive numbers. Taking ln|y| instead works on both sides, and the derivative of ln|u| is u′/u, the same as that of ln u. The page writes ln y with bars; the derivative is the same either way.
Is the answer the same as the ordinary derivative?
Yes, wherever y is not 0: y · (y′/y) = y′. It is written in the log-differentiation form y times a sum, which is how textbooks leave it; multiplying out gives the form of the product and quotient rules.
How is the answer checked?
The computer algebra system differentiates ln y, and its derivative is compared with a numeric difference quotient at 20 points. The page also checks that the expanded ln y equals ln|y| at 18 test points. If a check fails, it says "No verified answer".