practicecalculus
Powers, roots and rational functions

Integral of 1/x: Formula, Derivation and Examples

The integral of 1/x is ln|x| + C. See why the power rule fails here, where the absolute value comes from, and how to handle 1/(ax + b) and f'/f.

Powers, roots and rational functions Updated 3 min read

At a glance

\int \frac{1}{x}\,dx = \ln\lvert x\rvert + C
Antiderivative
\ln\lvert x\rvert + C
Valid for
x \ne 0
Linear form
\int \dfrac{1}{ax + b}\,dx = \dfrac{1}{a}\ln\lvert ax + b\rvert + C
Log form
\int \dfrac{f'(x)}{f(x)}\,dx = \ln\lvert f(x)\rvert + C
Area from 1 to e
1
On this page
  1. Graph of 1/x and its antiderivative
  2. Why the power rule fails
  3. Where the absolute value comes from
  4. Check by differentiating
  5. Substitution variants
  6. Worked examples
  7. Common mistakes

The integral of \dfrac{1}{x} is \ln\lvert x\rvert + C. It is the one power of x that the reverse power rule cannot handle, and the natural log fills the gap.

\int \frac{1}{x}\,dx = \ln\lvert x\rvert + C, \qquad x \ne 0

Graph of 1/x and its antiderivative

Area under y = 1/x from 1 to e, with the antiderivative y = ln|x|
The shaded area from x = 1 to x = e is exactly 1. This is one way to define the number e. The dashed curve y = \ln\lvert x\rvert is the antiderivative on both sides of 0.

On the right, \frac{1}{x} > 0 and \ln x increases. On the left, \frac{1}{x} < 0 and \ln\lvert x\rvert decreases as you move right. The slopes match the heights in both cases.

Why the power rule fails

The reverse power rule says \int x^n\,dx = \frac{x^{n+1}}{n+1} + C. For \frac{1}{x} = x^{-1} that would give \frac{x^0}{0}, which is undefined. No power of x has derivative x^{-1}, because the derivative of x^0 = 1 is 0.

The function that does have derivative \frac{1}{x} is the natural log. The derivative of ln x page proves that \frac{d}{dx}\ln x = \frac{1}{x} for x > 0.

Where the absolute value comes from

For x < 0, \ln x is undefined, but \ln(-x) is fine. Differentiate it with the chain rule:

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

So \ln x works for x > 0 and \ln(-x) works for x < 0. Together they are \ln\lvert x\rvert.

Check by differentiating

For x > 0: \frac{d}{dx}\ln x = \frac{1}{x}. For x < 0: \frac{d}{dx}\ln(-x) = \frac{1}{x}. Both give \frac{1}{x}, so \frac{d}{dx}\ln\lvert x\rvert = \frac{1}{x} for all x \ne 0.

Substitution variants

With u = ax + b:

\int \frac{1}{ax + b}\,dx = \frac{1}{a}\ln\lvert ax + b\rvert + C

More generally, whenever the numerator is the derivative of the denominator, the answer is a log:

\int \frac{f'(x)}{f(x)}\,dx = \ln\lvert f(x)\rvert + C

This one pattern gives the integral of tan x, the integral of cot x and the integral of x/(x² + 1).

Worked examples

Example 1. \int \frac{5}{x}\,dx = 5\ln\lvert x\rvert + C.

Example 2. \int \frac{1}{3x - 2}\,dx = \frac{1}{3}\ln\lvert 3x - 2\rvert + C.

Example 3. \int \frac{2x + 3}{x^2 + 3x}\,dx = \ln\lvert x^2 + 3x\rvert + C, since the numerator is the derivative of the denominator.

Example 4: definite, positive side. \int_1^2 \frac{1}{x}\,dx = \ln 2 - \ln 1 = \ln 2 \approx 0.693.

Example 5: definite, negative side. \int_{-3}^{-1} \frac{1}{x}\,dx = \ln\lvert -1\rvert - \ln\lvert -3\rvert = -\ln 3. The answer is negative because the curve is below the axis there.

Common mistakes

  1. Using the power rule. \frac{x^0}{0} is meaningless. Use \ln\lvert x\rvert.
  2. Dropping the absolute value when x can be negative.
  3. Integrating across 0. \int_{-1}^{1}\frac{1}{x}\,dx is not \ln 1 - \ln 1 = 0. The integral diverges.
  4. Confusing it with \frac{1}{x^2}. \int \frac{1}{x^2}\,dx = -\frac{1}{x} + C, not a log. See the integral of 1/x².
  5. Forgetting the \frac{1}{a} in \int \frac{1}{ax + b}\,dx.

For a log-based integral that runs the other way, see the integral of ln x.

Practice it now

Sine, cosine, eˣ and 1/x

Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.

Practice this lesson

Frequently asked questions

What is the integral of 1/x?

The integral of \frac{1}{x} is \ln\lvert x\rvert + C. For x > 0 you can drop the bars and write \ln x + C.

Why is there an absolute value in ln|x|?

\ln x only exists for x > 0, but \frac{1}{x} also exists for x < 0. For negative x, the derivative of \ln(-x) is \frac{-1}{-x} = \frac{1}{x}, so \ln\lvert x\rvert covers both sides.

What is the integral of 1/(2x)?

It is \frac{1}{2}\ln\lvert x\rvert + C. Writing \frac{1}{2}\ln\lvert 2x\rvert + C is also correct, because it differs only by the constant \frac{1}{2}\ln 2.

What is the integral of 1/x from -1 to 1?

It does not exist. \frac{1}{x} has an infinite discontinuity at 0, and both halves of the improper integral diverge.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.