Stochastic Integration by Parts

Every calculus student can recite Leibniz's product rule: d(xy) = x\,dy + y\,dx. Its integral twin, integration by parts, is the single most-used trick in a first analysis course. In the stochastic world both survive — but each picks up one extra term, the quadratic covariation of the two factors. For Itô processes X, Y,

d(X_t Y_t) = X_t\,dY_t + Y_t\,dX_t + d[X, Y]_t,

and, integrating from 0 to T,

\int_0^T X_t\,dY_t = X_T Y_T - X_0 Y_0 - \int_0^T Y_t\,dX_t - [X, Y]_T.

Where does the intruder come from? Picture the classic proof of the product rule: a rectangle with sides X and Y grows a little on each side. The new area splits into two strips — X\,\Delta Y along the top, Y\,\Delta X up the side — plus a tiny corner square of area \Delta X\,\Delta Y. In ordinary calculus that corner is doubly small and dies in the limit, so Leibniz never mentions it. But when both sides wiggle like Brownian motion, each increment has size \sqrt{\Delta t} — so the corner has size \sqrt{\Delta t}\cdot\sqrt{\Delta t} = \Delta t. That is first order. The corner refuses to die, its accumulated total is exactly [X, Y]_T, and the whole difference between stochastic and classical calculus is that one surviving square.

The rule is also a direct application of Itô's lemma to f(x, y) = xy — we derive it that way below. But keep the growing rectangle in mind throughout: it is the honest picture of what the formula says.

The corner that refuses to die

Start with an exact algebraic identity — no calculus, no limits. Over any discrete step, however large,

\Delta(XY) = X_{t+\Delta t}Y_{t+\Delta t} - X_t Y_t = X_t\,\Delta Y + Y_t\,\Delta X + \Delta X\,\Delta Y.

(Multiply out (X + \Delta X)(Y + \Delta Y) and cancel — the corner term \Delta X\,\Delta Y is there exactly.) Everything hinges on what the sum of corners \sum_i \Delta X_i\,\Delta Y_i does as the partition refines.

Deterministic case — the corner dies. If X, Y are differentiable, each increment is \Delta X \approx X'\,\Delta t, so each corner is of order (\Delta t)^2. Summing n = T/\Delta t of them:

\sum_i \Delta X_i\,\Delta Y_i \;\sim\; \frac{T}{\Delta t}\cdot (\Delta t)^2 \;=\; T\,\Delta t \;\longrightarrow\; 0.

The corners vanish in the limit, and Leibniz's rule is what remains — which is exactly why your first-year textbook never showed you the corner.

Stochastic case — the corner survives. A Brownian increment over \Delta t has standard deviation \sqrt{\Delta t} — much bigger than \Delta t for small steps. So if both factors carry Brownian noise, each corner is of order \sqrt{\Delta t}\cdot\sqrt{\Delta t} = \Delta t, and the sum is of order

\sum_i \Delta X_i\,\Delta Y_i \;\sim\; \frac{T}{\Delta t}\cdot \Delta t \;=\; T \;\not\to\; 0.

The corners add up to something finite and non-random in the limit — the quadratic covariation [X, Y]_T. For the purest case X = Y = W this is the familiar \Delta W\,\Delta W \approx \Delta t, i.e. [W, W]_T = T. That single scaling difference — \sqrt{\Delta t} versus \Delta t — is the whole story of this page in one picture.

Deriving the product rule, line by line

Apply the two-variable Itô lemma to f(x, y) = xy. The two-variable form, for processes X, Y, reads

df = f_x\,dX + f_y\,dY + \tfrac{1}{2}\Big(f_{xx}\,d[X] + 2f_{xy}\,d[X,Y] + f_{yy}\,d[Y]\Big),

the second-order part now carrying the covariation cross-term 2f_{xy}\,d[X,Y] alongside the two pure variations.

Step 1 — compute the partials of f(x, y) = xy:

f_x = y, \qquad f_y = x, \qquad f_{xy} = 1, \qquad f_{xx} = 0, \qquad f_{yy} = 0.

Step 2 — substitute. The two pure second derivatives vanish, so the variation terms d[X] and d[Y] drop out entirely; only the cross term remains:

d(X_t Y_t) = y\,dX_t + x\,dY_t + \tfrac{1}{2}\cdot 2\cdot 1\cdot d[X, Y]_t.

Step 3 — write x = X_t, y = Y_t and simplify the \tfrac12\cdot 2 = 1:

d(X_t Y_t) = Y_t\,dX_t + X_t\,dY_t + dX_t\,dY_t.

Step 4 — recognise the cross-product as a covariation. From the box algebra, dX_t\,dY_t = d[X, Y]_t, which delivers the product rule:

\boxed{\,d(X_t Y_t) = Y_t\,dX_t + X_t\,dY_t + d[X, Y]_t.\,}

Integrating both sides over [0, T] and moving one integral across gives the integration-by-parts formula stated above. The extra -[X, Y]_T is the Itô tax on the classical rule. Because xy is linear in each variable separately, the pure curvature terms vanish and only the mixed term speaks: the product rule is Itô's lemma stripped to a single cross-derivative.

In explicit Itô-process coordinates: if dX_t = a_t\,dt + \sigma^X_t\,dW^1_t and dY_t = b_t\,dt + \sigma^Y_t\,dW^2_t with d[W^1, W^2]_t = \rho\,dt, the box algebra (dt\,dt = dt\,dW = 0, dW^1\,dW^2 = \rho\,dt) evaluates the correction to

d[X, Y]_t = \sigma^X_t\,\sigma^Y_t\,\rho\,dt.

Two volatilities and a correlation: the correction is a genuine dt-term, a drift created purely by the interaction of two noises. Set \rho = 0, or kill either volatility, and it is gone.

Sanity check: d(W\cdot W) and the famous \int W\,dW

The best stress-test of a new rule is a case whose answer we already know. Set X_t = Y_t = W_t, so the "product" is just W_t^2. The product rule gives

d(W_t^2) = W_t\,dW_t + W_t\,dW_t + d[W, W]_t = 2W_t\,dW_t + dt,

using d[W, W]_t = dt — exactly the d(W_t^2) that single-variable Itô's lemma produces from f(w) = w^2. The two routes agree, as they must. Now integrate from 0 to T (with W_0 = 0):

W_T^2 = 2\int_0^T W_t\,dW_t + T \qquad\Longrightarrow\qquad \int_0^T W_t\,dW_t = \tfrac12 W_T^2 - \tfrac12 T.

There it is — the most famous computation in stochastic calculus, recovered as a two-line consequence of the product rule. Classical calculus would have claimed \int_0^T W\,dW = \tfrac12 W_T^2; the missing -\tfrac12 T is half the accumulated corner, \tfrac12[W, W]_T. Sanity-check the sign with expectations: the Itô integral is a martingale, so \mathbb{E}\!\int_0^T W\,dW = 0, and indeed \mathbb{E}\big[\tfrac12 W_T^2 - \tfrac12 T\big] = 0. The naive answer would have expectation \tfrac12 T > 0 — a "free lunch" from nothing, which is how you know it must be wrong.

A worked example: d(t\,W_t) and \int_0^T t\,dW_t

Take X_t = t (pure drift, dX_t = dt) and Y_t = W_t (dY_t = dW_t). The covariation term d[t, W]_t = 0, because t has finite variation — it is smooth, so it accumulates no covariation with anything (formally its diffusion coefficient \sigma^X = 0, and dt\,dW = 0 in the box algebra). Then

d(t\,W_t) = t\,dW_t + W_t\,dt + \underbrace{d[t, W]_t}_{=\,0} = W_t\,dt + t\,dW_t.

This one has no correction — the ordinary product rule already holds, precisely because one factor is smooth. Now integrate from 0 to T (using 0\cdot W_0 = 0) and rearrange to evaluate an otherwise-awkward Itô integral:

T\,W_T = \int_0^T W_t\,dt + \int_0^T t\,dW_t \;\;\Longrightarrow\;\; \int_0^T t\,dW_t = T\,W_T - \int_0^T W_t\,dt.

Integration by parts has traded an integral against dW (a stochastic integral) for one against ordinary dt — exactly the kind of simplification that makes the formula a workhorse in pricing. Compare the two worked examples side by side: W\cdot W (both factors rough) needed the correction; t\cdot W (one factor smooth) did not. Diagnosing which regime you are in is the practical skill this page teaches.

For Itô processes X, Y:

The classic hand-derivation error in this subject is writing d(XY) = X\,dY + Y\,dX out of pure classical habit and pressing on. The mistake is silent — the algebra still "works" — but every downstream drift is wrong. The canonical casualty: claiming W_T^2 = 2\int_0^T W\,dW. It is false — the left side has expectation T, the right side has expectation 0 (an Itô integral is a martingale). The missing +T is exactly the covariation term the naive rule drops.

The equally important flip side: know which regime you are in, because the correction is not always there either. It vanishes when either factor is smooth / has finite variation (so d(t\,W) = W\,dt + t\,dW needs no fixing), and when the two noises are uncorrelated (\rho = 0 \Rightarrow d[X,Y] = 0). Writing a correction that should be zero is as wrong as dropping one that shouldn't. The two-second diagnostic before any product: do both factors carry a dW, and are those dWs correlated? Yes and yes → correction. Anything else → Leibniz.

Where it bites: the value of a portfolio

Here is the place every quant meets this rule for real. Suppose you hold \varphi_t shares of a stock S_t. The value of that position is the product V_t = \varphi_t S_t, and the naive book-keeping instinct says your wealth changes only because the price moves: dV = \varphi\,dS. The product rule says otherwise:

d(\varphi_t S_t) = \varphi_t\,dS_t + S_t\,d\varphi_t + d[\varphi, S]_t.

The middle term is intuitive — if you buy more shares, the position grows. It is the third term that classical thinking misses entirely. If your strategy is static (\varphi constant, or changing smoothly and deterministically), then \varphi has finite variation, d[\varphi, S] = 0, and the naive picture is fine. But a delta hedge is nothing like static: \varphi_t = \Delta(t, S_t) is a function of the price itself, so \varphi is an Itô process driven by the same Brownian motion as S. The strategy and the price wiggle together, d[\varphi, S]_t \neq 0, and the corner term is a genuine, systematic cash flow.

Concretely: when the price jumps up, a delta hedger of a sold call buys more stock (delta rose), and when it drops they sell — buying high, selling low, continuously. That steady bleed is d[\varphi, S] made flesh: the cost of gamma, which option prices must (and do) compensate. The self-financing condition — that a strategy (\varphi_t, \psi_t) in stock and bank account funds all rebalancing internally, dV_t = \varphi_t\,dS_t + \psi_t\,dB_t — is exactly the demand that the other product-rule terms, S\,d\varphi + d[\varphi, S] (plus the bank-account twin), net to zero. Forget the covariation term and your "self-financing" replication argument silently leaks money; the Black–Scholes derivation itself comes out wrong.

A daily-rebalanced 2× leveraged ETF L_t promises twice the stock's return each instant: dL/L = 2\,dS/S. You might guess that over a long stretch it delivers the squared gross return, L_T/L_0 = (S_T/S_0)^2. Check with the product rule (with dS = \sigma S\,dW, drift set to zero for clarity): setting X = Y = S,

d(S^2) = 2S\,dS + d[S, S] = 2S\,dS + \sigma^2 S^2\,dt \;\;\Longrightarrow\;\; \frac{d(S^2)}{S^2} = 2\,\frac{dS}{S} + \sigma^2\,dt.

So the squared price grows \sigma^2\,dt faster than twice the return — the covariation term again. The ETF, which delivers exactly 2\,dS/S and no more, therefore lags the square by that amount, compounding to

\frac{L_T}{L_0} = \left(\frac{S_T}{S_0}\right)^{2} e^{-\sigma^2 T}.

If the stock ends flat (S_T = S_0) after a volatile year with \sigma = 30\%, the 2× fund is down 1 - e^{-0.09} \approx 8.6\% — on an underlying that went nowhere. Traders call it volatility drag; you can now see it is nothing mysterious, just the product rule's correction term quietly eating returns. The same calculation, run through the general Itô lemma, is why fund prospectuses warn that leveraged ETFs are "not suitable for buy-and-hold investors."

The independent case: Leibniz comes home

One more regime completes the map. Let X and Y both be genuinely rough — dX = \sigma^X dW^1, dY = \sigma^Y dW^2 — but driven by independent Brownian motions, so d[W^1, W^2]_t = 0. Then the correction d[X, Y]_t = \sigma^X \sigma^Y \cdot 0 \cdot dt = 0, and

d(X_t Y_t) = X_t\,dY_t + Y_t\,dX_t.

Leibniz's rule, verbatim — even though both factors are nowhere-differentiable Brownian paths! The intuition sits in the corner picture: the corners \Delta X_i\,\Delta Y_i are still individually of order \Delta t, but with independent drivers they carry random signs, and the law of large numbers cancels them as the partition refines. They only pile up in one direction when the noises are correlated — which is why the surviving term is \rho\,\sigma^X \sigma^Y\,dt. A useful corollary: for independent driftless factors \mathbb{E}[X_T Y_T] = X_0 Y_0; with \rho \neq 0, \mathbb{E}[X_T Y_T] - X_0 Y_0 = \mathbb{E}\,[X, Y]_T — the correction is covariance accruing in real time.

So the full regime map has three territories: one factor smooth → no correction; both rough, independent → no correction (corners cancel); both rough, correlated → correction \rho\,\sigma^X\sigma^Y\,dt, with the extreme case X = Y (correlation one with itself) giving the full quadratic variation.

The extra term as an area mismatch

Now watch the growing rectangle become a theorem. Integration by parts is the statement that the rectangle of area X_T Y_T is filled by two strips, \int X\,dY and \int Y\,dX. In ordinary calculus those two strips tile the rectangle exactly. For rough Itô paths they overlap by a thin staircase of cross-increments \sum \Delta X_i\,\Delta Y_i — and that staircase is precisely the covariation [X, Y]_T, the term the classical formula is missing.

In the figure, the path climbs from the origin to (X_T, Y_T). The shaded cells under the path are the Riemann cells of \int Y\,dX (height Y_i, width \Delta X_i); the unshaded remainder above the path is \int X\,dY. The small bright squares hugging the path are the corners \Delta X_i\,\Delta Y_i — the diagonal staircase neither strip can claim. For smooth paths it pinches to nothing; for Brownian-driven paths it converges to the finite area [X, Y]_T. Press Refresh for a fresh random path: the strips and staircase change, but the relationship never does — \int X\,dY + \int Y\,dX + [X, Y]_T = X_T Y_T.