1. Home
  2. Blog
  3. Derivative of ln x

Why the derivative of ln x is 1/x, and why ln|x| has the same one

The derivative of lnx is 1x: write y=lnx as ey=x, differentiate both sides, and it falls out in three lines. The function ln|x| has the same derivative, 1x, on both sides of zero, and that is exactly why the integral of 1x is ln|x|+C rather than lnx+C.

Start from what ln x means

lnx is the logarithm in base e, and its whole definition is that it undoes ex:

y=lnxmeansey=x.

Two facts come with that sentence, and both are used below.

  • ey is positive for every y, so lnx exists only for x>0. Its domain is (0,∞).
  • The graph of y=lnx is the graph of y=ex reflected in the line y=x: every point (a,b) on one becomes the point (b,a) on the other.

Getting 1/x in three lines

Rewrite y=lnx in exponential form and differentiate both sides with respect to x. This is implicit differentiation: y depends on x, so the left side needs the chain rule.

  1. Rewrite. ey=x.
  2. Differentiate both sides. eydydx=1.
  3. Solve, then use the definition once more. ey is x, so dydx=1ey=1x.

So ddxlnx=1x for every x>0. Step 3 is the one to remember: the answer first comes out in terms of y, and the definition ey=x is what turns it back into x. The same move gives the derivatives of the inverse trigonometric functions.

The same fact, on the graph

Reflecting in y=x swaps rise and run, so a tangent of slope m becomes a tangent of slope 1m. On y=ex the point (2,e2) has slope e2, because ex is its own derivative. Its mirror image on y=lnx is the point (e2,2), where the slope is therefore 1e2: exactly 1x at x=e2. Every point pairs up the same way.

Why ln|x| has the same derivative

ln|x| is defined for every x≠0, because |x| is positive on both sides of zero. Split it at zero and differentiate each piece.

  • For x>0: |x|=x, so ln|x|=lnx, whose derivative is 1x.
  • For x<0: |x|=−x, so ln|x|=ln(−x), and the chain rule gives ddxln(−x)=1−x·(−1)=1x.

The two minus signs cancel, so both pieces give the same formula:

ddxln|x|=1xfor every x≠0.

Notice that 1x is negative when x<0. The graph says the same thing: y=ln|x| is the graph of lnx together with its mirror image in the y-axis, and a mirror in the y-axis reverses the sign of every slope. The right branch rises, and the left branch falls as x moves towards zero.

x y −6 −4 −2 2 4 6 −2 −1 1 2 (2, ln 2) (−2, ln 2) slope 1/2 slope −1/2 y = ln|x|
y=ln|x| with its tangent lines at x=2 and x=−2. The slopes are 12 and −12, the value of 1x at each point.

Why the integral of 1/x is ln|x| + C

An antiderivative of 1x has to work wherever you need it, and 1x is perfectly well defined for negative x.

  • lnx+C has derivative 1x on (0,∞) only. For negative x it does not exist at all.
  • ln|x|+C has derivative 1x on (0,∞) and on (−∞,0).

That is the whole reason for the absolute value:

∫1xdx=ln|x|+C.

It is still used on one interval at a time. Zero is not in the domain of 1x, so the formula applies on an interval of positive numbers or on an interval of negative numbers, never on one that contains 0.

Two worked examples

1. Differentiate f(x)=ln|x2−9|

Combine the chain rule with dduln|u|=1u, taking u=x2−9:

f′(x)=1x2−9·2x=2xx2−9,x≠±3.

The absolute value is doing real work here. On (−3,3) the inside is negative, so on that interval f(x)=ln(9−x2). Differentiating that piece directly:

ddxln(9−x2)=−2x9−x2=2xx2−9.

The same formula. ddxln|u|=u′u holds whatever the sign of u, so you never need to split into cases to differentiate. You only need the cases to know where the function exists.

2. Integrate 1x from −6 to −2

The interval [−6,−2] does not contain 0, so ln|x| is an antiderivative on all of it:

∫−6−21xdx=[ln|x|]−6−2=ln2−ln6,

and by the quotient law that is

ln26=ln13=−ln3.

Check the sign: 1x is negative on the whole interval, so the integral has to be negative, and −ln3≈−1.10 is. Try the same computation with lnx in place of ln|x| and the very first step asks for ln(−2), which does not exist.

The common slip: keeping the bars in the derivative. The derivative of ln|x| is 1x, with no absolute value anywhere. The tempting version puts |x| in the denominator as well, and that expression is positive for every x≠0, so it would make the left branch rise. The left branch falls: at x=−1 the slope of ln|x| is −1.

The same slip in reverse happens with integrals: lnx+C for the integral of 1x. That answer is right on (0,∞) and nowhere else, so it is acceptable only when the question has already restricted x to positive values.

Check your understanding

No calculator. The first three are quick; the rest ask for a reason as well as an answer.

  1. The tangent to y=ex at x=3 has slope e3. Without differentiating lnx, give the slope of the tangent to y=lnx at the point (e3,3).
  2. Find the slope of y=ln|x| at x=−5, and say whether the graph is rising or falling there.
  3. Differentiate g(x)=ln|4−x|, and state where your derivative is valid.
  4. True or false, with a reason: on the interval (2,9), lnx+C is just as good an antiderivative of 1x as ln|x|+C.
  5. Differentiate ln|cosx|. What antiderivative of tanx does your answer give you, and why does it need the absolute value?
  6. Use the method of this post, writing y=log10x as 10y=x, to find the derivative of log10x.
  7. Calculus II: evaluate ∫−e2−11xdx.
  8. Calculus II: find the error. A student writes ∫−321xdx=ln|2|−ln|−3|=ln23.
Show the answers
  1. 1e3. Reflecting in y=x swaps rise and run, so the slope becomes the reciprocal of e3. It agrees with 1x at x=e3.
  2. −15, so the graph is falling. The derivative of ln|x| is 1x, which is negative for every x<0.
  3. g′(x)=1x−4 for every x≠4. The chain rule gives 14−x·(−1)=−14−x, which is 1x−4; thanks to the bars, it holds on both sides of 4.
  4. True. Every x in (2,9) is positive, so |x|=x and the two expressions are the same function there. The bars only change anything on an interval of negative numbers.
  5. ddxln|cosx|=−sinxcosx=−tanx, so −ln|cosx|+C is an antiderivative of tanx on any interval where cosx≠0. The bars are needed because cosx is negative on intervals such as (π2,3π2), where tanx is still defined.
  6. 1xln10. Differentiating 10y=x gives 10yln10·dydx=1, so dydx=110yln10, and 10y=x.
  7. −2. The interval [−e2,−1] avoids 0, so ln|−1|−ln|−e2|=0−2=−2. It is negative, as it must be: 1x<0 on the whole interval.
  8. The interval [−3,2] contains 0, where 1x is undefined, so ln|x| is not an antiderivative on the whole interval and the subtraction is not allowed. The integral is improper, and it has no value: the piece from −3 to 0 alone already diverges to −∞.

Practise it

The free CEGEP Calculus I Derivatives of Transcendental Functions worksheet has logarithmic derivatives with their domains to state, logarithmic differentiation, and the rest of the family: exponentials, trigonometric and inverse trigonometric functions. The questions are on the page, with a printable PDF.

Want one-on-one help with this? I offer CEGEP Science calculus and linear algebra tutoring in Montreal, in person or online. Sessions start with a short written diagnostic, and a written recap goes to whoever books after every session.

Free worksheets on this topic

Ready to improve your grades?

WhatsApp is the way to reach me — tell me the course you're taking and what you're stuck on, and we'll sort out a first session from there.

Message Me on WhatsApp

or send a message

I reply within a day, usually sooner. Your details are used only to answer you — see the Privacy Policy.

Private math & science tutoring in Montreal, QC — Westmount · Outremont · Town of Mount Royal · Hampstead · Côte-Saint-Luc · NDG · Nuns' Island · West Island — and online across Quebec.

Chat with Marius