- Introduced by
- Mike Giles, Iman Homescu
- Year
- 2008
- Type
- Sensitivity Analysis
- Family
- Computational Methods
What does it do?
Automatic differentiation (AD) computes derivatives of a pricing function, such as option Greeks, by applying the chain rule to the code that evaluates the price.
Unlike finite differences, it does not require bumping inputs and repricing, and unlike hand derivation, it does not require closed-form sensitivity formulas. The derivatives are exact for the code as implemented, including its discretisation and any simulated sample, up to floating-point rounding. They approximate the Greek of the underlying model only to the extent that the numerical method converges.
The intuition behind the method
Greeks can be obtained in three broad ways: by bumping an input and repricing (finite differences), by deriving sensitivity formulas by hand, or by differentiating the pricing code itself. Finite differences depend on the bump size and inherit rounding error, and hand derivation becomes laborious once the model or payoff is complicated. AD takes the third route: each elementary operation in the code has a known local derivative, and the chain rule combines these into the derivative of the final price with respect to any chosen input. Because the derivative is propagated through the same operations that produce the price, the extra cost is usually a modest multiple of the cost of pricing alone. The result is only as meaningful as the code: if the pricer is not differentiable at the points where it is evaluated, the returned derivative is not the Greek of the intended model.
History
Automatic differentiation is a general computational technique for evaluating derivatives of functions specified by computer programs. Its foundational treatment is given by Griewank and Walther (2008), Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation (SIAM). Its use for sensitivities in computational finance, including adjoint (reverse-mode) methods, rests on this general theory.
When to use it
Choose AD when the price is produced by a numerical procedure, such as Monte Carlo simulation, a PDE solver or a lattice, and analytical Greeks are unavailable or laborious to derive, especially when several sensitivities are needed from the same pricing run. Reverse mode is the natural choice when one price depends on many inputs, because all input sensitivities come from one backward pass. Forward mode suits a single sensitivity or a small number of inputs. Do not rely on AD when the pricer contains discontinuous branches or payoffs that have not been smoothed, since the derivative will not reflect the intended Greek at those points. When a closed-form Greek exists and is inexpensive to compute, it is usually the simpler and more transparent option. Pricers with early exercise need extra care, because the exercise decision is non-smooth and AD derivatives should be checked near the exercise boundary.
Limitations and considerations
- Tooling dependency: derivatives are obtained through AD-capable tools or libraries, which must support every operation used in the pricer.
- Code structure: the result depends on the pricer being differentiable along the evaluated paths. Conditionals, loops whose behaviour depends on data, and non-smooth functions such as max or absolute value need special handling.
- Memory in reverse mode: the recorded intermediate values must be stored for the backward pass, which can be costly for long simulations or large grids.
- Higher-order sensitivities: second-order Greeks such as gamma, and third-order Greeks such as speed or colour, require nested differentiation. They are not a by-product of a single first-order pass and add implementation complexity and cost.
- Early exercise: American and Bermudan features introduce optimal-exercise decisions, which are discrete and non-smooth. AD through the exercise boundary is not automatically valid. Smooth the exercise policy, or check AD Greeks against finite differences near the exercise boundary before relying on them.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Exact sensitivities for the code as written: derivatives are propagated through each operation, avoiding the truncation and rounding error that comes from choosing a bump size in finite differences.
- No hand derivation for the specific payoff or numerical scheme: the same procedure applies to Monte Carlo, PDE and tree pricers once the pricer is written in a differentiable form.
- Several sensitivities from one run in reverse mode: all derivatives with respect to the inputs are obtained from a single backward pass over the recorded computation.
- Cost tied to the pricing computation rather than to repeated repricing: each bump in bump-and-reprice needs a full additional pricing run, whereas AD adds derivative propagation to the existing run.
Applications
- Risk sensitivities for Monte Carlo pricers, where derivatives are propagated through simulated payoffs.
- Greeks for path-dependent or exotic payoffs for which closed-form sensitivities are not available.
- Jacobians of model outputs with respect to parameters, used in calibration routines that require gradients.
- Recomputing sensitivities after market moves, where repeated bump-and-reprice would be too costly.
How it works
How it works
Write the pricing routine so that it takes the inputs (for example spot, volatility and rates) and returns the price. The AD tool works on this code, so it must be written with operations the tool can trace.
Evaluate the price once while recording the sequence of elementary operations. In reverse mode, this recorded trace is traversed backward, applying the chain rule to accumulate derivatives with respect to all inputs. Forward mode instead carries derivatives alongside the values in a single forward pass for one chosen input direction.
Read off the sensitivity of the price with respect to each input of interest, such as delta as the derivative of price with respect to spot. In reverse mode, several Greeks are components of the same accumulated result, so they come from one backward pass.
Formula
\frac{\partial V}{\partial x} \text{ computed by forward or reverse mode AD}Check the derivatives against closed-form Greeks where a benchmark exists, and against finite-difference estimates computed with a suitable step size. A finite-difference estimate is itself sensitive to the bump size, so it is a rough check rather than a reference. Disagreement is expected at points where the code is not smooth.
Common pitfalls
- Non-smooth code: if-then-else branches and functions such as max or absolute value produce undefined or piecewise derivatives at the switching points. A smooth approximation changes the price slightly, so it should be checked against the original payoff.
- Discounting: AD differentiates whatever the code computes, so an incorrect discount factor or discount-curve input yields internally consistent but wrong sensitivities. The discounting step should be verified separately.
- Noisy Monte Carlo gradients: derivatives estimated from simulated paths carry sampling variance, so Greeks can be unstable without variance reduction. Common remedies are antithetic sampling and control variates.
- Mode choice: forward mode needs one pass per input to build a full set of sensitivities, which becomes slow as the number of inputs grows. Reverse mode is usually preferred for a complete set of Greeks from one price.
- Discontinuous Monte Carlo payoffs: for digital options and barrier crossings, pathwise AD gives zero or biased derivatives because the payoff is not differentiable along the simulated path. Use a likelihood-ratio estimator or a smoothed payoff, and check the result against a finite-difference estimate with common random numbers and a large sample.
Frequently asked questions
What is the difference between forward and reverse mode AD?
Forward mode propagates derivatives alongside the values in the direction of computation, giving the sensitivity of all outputs to one chosen input per pass. Reverse mode propagates adjoints backward from the output, giving the sensitivity of one output to all inputs in a single pass. For a pricing function with one output and several inputs, reverse mode is generally the more efficient choice, which is why it is commonly used to obtain a set of Greeks.
How much slower is AD than the original pricing code?
The overhead depends on the pricer, the mode and the implementation, so no single factor applies. Reverse mode adds a backward pass and storage for intermediate values, whereas bump-and-reprice needs a full repricing for each bumped input, which becomes costly as the number of inputs grows. Benchmark the specific pricer before relying on any speed claim.
Can I use AD for Monte Carlo pricing?
Yes, for payoffs that are smooth along each simulated path. AD differentiates each path's payoff and averages the derivatives across paths to estimate the Greek. Path-level estimates have high variance, so the result is usually combined with variance-reduction techniques such as antithetic sampling or control variates. For discontinuous payoffs, such as digital options or barrier crossings, pathwise derivatives are zero or biased, so a likelihood-ratio estimator or a smoothed payoff is needed.
What if my code has if-statements?
AD handles differentiable code best. For non-smooth branches, such as a test of whether spot exceeds strike, use smooth approximations, or separate the code into smooth regimes and differentiate each regime separately.
Related methods
Sources
Giles, M. B. (2008). Adjoint code by automatic differentiation. Journal of Computational Finance, 12(1), 1-18.
Open publication referenceHomescu, C. (2011). Adjoints and automatic differentiation in computational finance. arXiv:1107.1188.
Open publication referenceMathematics for Machine Learning, references list (entry for Griewank and Walther, 2008, Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation, SIAM), p. ?