In short

Integration by cancellation exploits a specific structure: the integrand contains two terms that, when you differentiate their combined antiderivative, cancel each other out — leaving only the original integrand. The most important instance is \int e^x\bigl[f(x) + f'(x)\bigr]\,dx = e^x f(x) + C. Recognising this pattern turns seemingly difficult integrals into one-line answers.

Here is an integral that looks unreasonable:

\int e^x\!\left(\frac{1}{x} - \frac{1}{x^2}\right)dx

Try the standard toolkit. Substitution? There is no clean inner function whose derivative appears outside. Integration by parts? You could try u = 1/x, dv = e^x\,dx, and it works — but watch what happens. By parts:

\int e^x \cdot \frac{1}{x}\,dx = \frac{e^x}{x} - \int e^x\!\left(-\frac{1}{x^2}\right)dx = \frac{e^x}{x} + \int \frac{e^x}{x^2}\,dx

Rearrange:

\int e^x \cdot \frac{1}{x}\,dx - \int \frac{e^x}{x^2}\,dx = \frac{e^x}{x}
\int e^x\!\left(\frac{1}{x} - \frac{1}{x^2}\right)dx = \frac{e^x}{x} + C

The second integral cancelled the one generated by integration by parts. That is not a coincidence. It happened because the two terms inside the parentheses — \frac{1}{x} and -\frac{1}{x^2} — are related: -\frac{1}{x^2} is the derivative of \frac{1}{x}.

The integrand was e^x\bigl[f(x) + f'(x)\bigr] in disguise, with f(x) = 1/x. And the antiderivative is simply e^x f(x).

This is integration by cancellation: a method where the answer comes not from grinding through mechanics, but from noticing that pieces of the integrand are set up to cancel when differentiated.

The key identity

Here is the pattern that makes cancellation work.

The $e^x[f(x) + f'(x)]$ identity

For any differentiable function f:

\int e^x\bigl[f(x) + f'(x)\bigr]\,dx = e^x f(x) + C

Why this is true. Differentiate the right side using the product rule:

\frac{d}{dx}\bigl[e^x f(x)\bigr] = e^x f(x) + e^x f'(x) = e^x\bigl[f(x) + f'(x)\bigr]

That is exactly the integrand. The product rule for e^x f(x) generates two terms — and those two terms are precisely the two pieces you started with. The cancellation is happening inside the product rule: e^x differentiates to itself, so when you differentiate e^x f(x), you get the original e^x f(x) term plus an extra e^x f'(x) from differentiating f. The integral reverses this.

The entire trick rests on one fact: e^x is its own derivative. No other function has this property (up to constant multiples), which is why the pattern is specific to e^x.

Recognising the pattern

The hard part is not the formula — it is seeing that an integral has this structure. Here is how to check.

Given \int e^x\bigl[g(x) + h(x)\bigr]\,dx, ask: is h(x) = g'(x)? If yes, the answer is e^x g(x) + C.

Some common instances:

Integrand f(x) f'(x) Answer
e^x(\sin x + \cos x) \sin x \cos x e^x \sin x + C
e^x(\cos x - \sin x) \cos x -\sin x e^x \cos x + C
e^x\!\left(\frac{1}{x} - \frac{1}{x^2}\right) \frac{1}{x} -\frac{1}{x^2} \frac{e^x}{x} + C
e^x\!\left(\frac{x-1}{x^2}\right) \frac{1}{x} -\frac{1}{x^2} \frac{e^x}{x} + C
e^x\!\left(\frac{1+x}{(1+x^2)}\right) Does not fit

The fourth row is the same as the third, just combined into a single fraction: \frac{x-1}{x^2} = \frac{1}{x} - \frac{1}{x^2}. Recognising this requires practice — sometimes the two pieces are combined and you have to split them apart to see the pattern.

The fifth row does not fit: \frac{d}{dx}\!\left(\frac{1}{1+x^2}\right) = \frac{-2x}{(1+x^2)^2}, which is not the second piece. Not every e^x \cdot (\text{something}) integral is a cancellation integral.

The generalised form: e^{ax} and beyond

The identity extends to e^{ax} with a small adjustment. Since \frac{d}{dx}[e^{ax}] = ae^{ax}:

\frac{d}{dx}\bigl[e^{ax} f(x)\bigr] = ae^{ax}f(x) + e^{ax}f'(x) = e^{ax}\bigl[af(x) + f'(x)\bigr]

So:

\int e^{ax}\bigl[af(x) + f'(x)\bigr]\,dx = e^{ax}f(x) + C

For example, \int e^{2x}(2\tan x + \sec^2 x)\,dx = e^{2x}\tan x + C, because f(x) = \tan x, f'(x) = \sec^2 x, and a = 2.

Beyond e^x: other cancellation structures

The e^x identity is the most common cancellation pattern, but it is not the only one. The underlying principle — look for a product whose derivative produces an extra term that matches something already in the integrand — appears in other forms.

Derivative of xf(x). By the product rule:

\frac{d}{dx}[xf(x)] = f(x) + xf'(x)

So \int [f(x) + xf'(x)]\,dx = xf(x) + C.

For instance: \int [\ln x + 1]\,dx. Here f(x) = \ln x and f'(x) = 1/x, so f(x) + xf'(x) = \ln x + 1. The antiderivative is x\ln x + C.

Derivative of \frac{f(x)}{g(x)}. By the quotient rule:

\frac{d}{dx}\!\left[\frac{f(x)}{g(x)}\right] = \frac{f'(x)g(x) - f(x)g'(x)}{[g(x)]^2}

If you see an integrand of the form \frac{f'g - fg'}{g^2}, the answer is f/g + C. This is especially useful when g(x) is something like \sin x or \cos x.

For instance: \int \frac{\cos x \cdot \cos x - \sin x \cdot (-\sin x)}{\cos^2 x}\,dx = \int \frac{\cos^2 x + \sin^2 x}{\cos^2 x}\,dx = \int \sec^2 x\,dx = \tan x + C. Here f = \sin x, g = \cos x, and the integral is \sin x / \cos x = \tan x.

That example is trivial — you already know \int \sec^2 x\,dx = \tan x — but the same structure appears in harder integrals where the quotient-rule pattern is the only clean path.

Example 1: The $e^x$ cancellation pattern

Evaluate \displaystyle\int e^x\!\left(\frac{x^2 + 1}{(x+1)^2}\right)dx.

Step 1. Rewrite the fraction so it splits into an f + f' pair. Write x^2 + 1 = (x+1)(x-1) + 2:

\frac{x^2+1}{(x+1)^2} = \frac{x-1}{x+1} + \frac{2}{(x+1)^2}

Why: performing polynomial division of x^2+1 by (x+1) in the numerator, or simply verifying \frac{x-1}{x+1} + \frac{2}{(x+1)^2} = \frac{(x-1)(x+1)+2}{(x+1)^2} = \frac{x^2-1+2}{(x+1)^2} = \frac{x^2+1}{(x+1)^2}.

Step 2. Check whether the two pieces form an f + f' pair.

Let f(x) = \frac{x-1}{x+1}. Then:

f'(x) = \frac{(x+1)(1) - (x-1)(1)}{(x+1)^2} = \frac{2}{(x+1)^2}

The second piece is f'(x). The integrand is e^x[f(x) + f'(x)].

Why: this confirms the cancellation pattern. The two terms are not random — one is the derivative of the other.

Step 3. Apply the identity.

\int e^x\!\left(\frac{x^2+1}{(x+1)^2}\right)dx = e^x \cdot \frac{x-1}{x+1} + C

Why: directly from \int e^x[f + f']\,dx = e^x f + C, with f(x) = (x-1)/(x+1).

Step 4. Verify by differentiating.

\frac{d}{dx}\!\left[e^x\cdot\frac{x-1}{x+1}\right] = e^x\cdot\frac{x-1}{x+1} + e^x\cdot\frac{2}{(x+1)^2} = e^x\cdot\frac{x^2+1}{(x+1)^2} \checkmark

Why: the product rule produces exactly the two terms that appeared in the split.

Result: \displaystyle\int e^x\!\left(\frac{x^2+1}{(x+1)^2}\right)dx = \frac{(x-1)\,e^x}{x+1} + C.

The integrand $e^x \cdot \frac{x^2+1}{(x+1)^2}$. The vertical asymptote at $x = -1$ comes from the denominator. On either side, the function is smooth. The antiderivative $\frac{(x-1)e^x}{x+1}$ has the same asymptote, and its derivative reproduces this curve exactly.

Example 2: The $xf'(x) + f(x)$ pattern

Evaluate \displaystyle\int \bigl[\cos(\ln x) + \sin(\ln x)\bigr]\,\frac{dx}{x} \cdot x.

Simplify the integrand first. The expression is:

\int \bigl[\cos(\ln x) + \sin(\ln x)\bigr]\,dx

Step 1. Suspect a cancellation pattern. Try f(x) = x\cos(\ln x) as a candidate antiderivative.

Why: if the answer is xg(\ln x) for some function g, then differentiating using the product rule will produce both g(\ln x) and x \cdot g'(\ln x) \cdot (1/x) = g'(\ln x). That gives two terms — matching the two terms in the integrand.

Step 2. Differentiate the candidate.

\frac{d}{dx}[x\sin(\ln x)] = \sin(\ln x) + x \cdot \cos(\ln x) \cdot \frac{1}{x} = \sin(\ln x) + \cos(\ln x)

Why: the product rule gives two terms. The x and 1/x from the chain rule cancel, leaving a clean sum.

Step 3. Compare with the integrand.

The derivative of x\sin(\ln x) is \sin(\ln x) + \cos(\ln x), which is exactly the integrand (with the terms in reversed order — addition is commutative).

Why: this confirms the guess. The structure f(x) + xf'(x) \cdot (1/x) collapsed to f(x) + f'(\ln x), matching the integrand.

Step 4. Write the result.

\int [\cos(\ln x) + \sin(\ln x)]\,dx = x\sin(\ln x) + C

Why: since differentiating x\sin(\ln x) gives the integrand, x\sin(\ln x) is the antiderivative.

Result: \displaystyle\int [\cos(\ln x) + \sin(\ln x)]\,dx = x\sin(\ln x) + C.

The solid curve is the integrand $\cos(\ln x) + \sin(\ln x)$. The dashed curve is the antiderivative $x\sin(\ln x)$. At every point, the slope of the dashed curve equals the height of the solid curve — exactly the relationship between a function and its antiderivative.

Common confusions

Going deeper

If you can recognise and apply the e^x[f + f'] identity and the f + xf' identity, you have the core skill. The material below shows why these are special cases of a single idea, and how to handle situations where the pattern almost — but not quite — applies.

The unifying principle: reverse the product rule

Every cancellation identity is the product rule run backward. If you suspect the antiderivative is u(x) \cdot v(x), then:

\frac{d}{dx}[u(x)v(x)] = u'(x)v(x) + u(x)v'(x)

So \int [u'v + uv']\,dx = uv + C. The integrand must decompose into two terms, one involving u' and one involving v', with the other factor matching.

The e^x identity uses u = e^x, v = f(x). Then u' = e^x and v' = f'(x), so u'v + uv' = e^x f + e^x f' = e^x(f + f').

The xf(x) identity uses u = x, v = f(x). Then u' = 1 and v' = f'(x), so u'v + uv' = f + xf'.

The quotient-rule variant uses u = f(x), v = 1/g(x), and the rest follows.

Once you see the product rule as the source, you can handle non-standard cases. For example:

\int [\sin x \cdot f(x) + \cos x \cdot f'(x)]\,dx

This does not match e^x(f + f'). But \frac{d}{dx}[\sin x \cdot f(x)] = \cos x \cdot f(x) + \sin x \cdot f'(x), which is almost but not quite the integrand — the roles of f and f' are swapped. So this particular integral needs a different approach (likely integration by parts). Recognising what does not fit is as important as recognising what does.

When the pattern almost works: adding and subtracting

Sometimes the integrand is close to e^x(f + f') but has an extra constant. For example:

\int e^x\!\left(\frac{1}{x} - \frac{1}{x^2} + \frac{3}{x^3}\right)dx

The first two terms give f(x) = 1/x, f'(x) = -1/x^2. The third term 3/x^3 is not part of this pair. So separate:

= \int e^x\!\left(\frac{1}{x} - \frac{1}{x^2}\right)dx + 3\int \frac{e^x}{x^3}\,dx

The first integral is e^x/x + C by cancellation. The second integral, \int e^x/x^3\,dx, does not have a closed form in elementary functions — it requires the exponential integral function \mathrm{Ei}(x).

This shows the limits of the method: cancellation only handles integrands that are exactly of the right form. A single extra term that does not fit can make the remaining piece non-elementary.

A useful diagnostic

When facing \int e^x \cdot h(x)\,dx, compute h(x) - h'(x). If the result is 2f(x) for some recognisable f, then h(x) = f(x) + f'(x) where f = (h - h')/2... but this only works when h - h' simplifies cleanly. In practice, pattern recognition — scanning the integrand for a function and its derivative sitting side by side — is faster than any systematic algorithm.

Where this leads next