# 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.

Source: https://practicecalculus.com/integrals/1-over-x
Updated: 2026-11-06

$$ \int \frac{1}{x}\,dx = \ln\lvert x\rvert + C $$

## At a glance

- **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$

## Key takeaways

- The integral of $\frac{1}{x}$ is $\ln\lvert x\rvert + C$, not a power of $x$.
- The reverse power rule breaks at $n = -1$ because it would divide by zero.
- The absolute value makes the formula work for negative $x$ too.
- More generally, $\int \frac{f'(x)}{f(x)}\,dx = \ln\lvert f(x)\rvert + C$.

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

```graph
title: 'Area under y = 1/x from 1 to e, with the antiderivative y = ln|x|'
caption: '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$.'
x: [-4, 4]
y: [-3, 3]
functions:
  - expr: 1/x
    label: y = 1/x
    domain: [0.25, 4]
  - expr: 1/x
    label: y = 1/x (x < 0)
    domain: [-4, -0.25]
  - expr: ln(abs(x))
    label: y = ln|x| (antiderivative)
    dashed: true
    domain: [-4, 4]
shade: {expr: 1/x, from: 1, to: 2.71828}
points:
  - [2.71828, 1, '(e, 1)']
```

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](/rules/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](/derivatives/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](/integrals/tan-x), the [integral of cot x](/integrals/cot-x) and the [integral of x/(x² + 1)](/integrals/x-over-x-squared-plus-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²](/integrals/1-over-x-squared).
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](/integrals/ln-x).

## 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.
