# How to calculate the local volatility from implied volatility in practice

The local volatility can be derived from the implied volatility. But in practice how we deal with the first-order and second-order derivatives?

I have seen this formula $$\sigma_{\mathrm{Dup}}(T, K)^{2}=\frac{\frac{\partial w}{\partial T}}{1-\frac{y}{w} \frac{\partial w}{\partial y}+\frac{1}{4}\left(-\frac{1}{4}-\frac{1}{w}+\frac{y^{2}}{w^{2}}\right)\left(\frac{\partial w}{\partial y}\right)^{2}+\frac{1}{2} \frac{\partial^{2} w}{\partial y^{2}}}$$

Source: Gatheral's "The Volatility Surface", p.13, eq. (1.10) https://quant.stackexchange.com/a/40363/16148

I also know that for the Dupire equation below, we can use the finite difference method as in Numerical example of how to calculate local vol surface from IV surface.

$$\sigma_{L}(k, T)=\sqrt{\frac{\frac{\partial C}{\partial T}}{\frac{1}{2} K^{2} \frac{\partial^{2} C}{\partial K^{2}}}}$$

If we are calculating local volatilities, it is usually because we want to calculate prices either by numerically solving a PDE, or by simulating in Monte Carlo. Depending which of these two approaches we are using, the practical approach differs slightly.

To begin with, we assume we are given a nice smooth volatility surface $$\sigma_\text{imp}(K, T)$$ where $$T$$ is time to expiry and $$K$$ is strike, interpolated from some source of volatilities (or backed out from prices).

The standard approach is to use your first formula (Gatheral eq 1.10). Irrespective of whether we are using PDE or Monte Carlo, we always have a time grid. It might, say, be 100 grid points between valuation time and option expiry. Or it might be a daily or weekly time schedule. The expiry derivative (the numerator in the local volatility formula) should always be calculated by finite difference on this time grid (with strike at fixed moneyness).

Traditionally, the strike (actually moneyness) derivatives are calculated analytically from the smooth implied volatility surface. In the PDE approach, we do this at each PDE spot grid point (and each time grid point). In the Monte Carlo approach, there is no spot grid, but we introduce one purely for the local volatilities. Then we create an interpolator, one for each time grid point, that interpolates the local volatilities from the spot grid. When simulating a spot path, we simulate spot rates forwards in time, and use the interpolator at the current time step to get the local volatility.

To understand why we use finite difference for the numerator, we note that in the case that there is no smile/skew it gives the exact Black-Scholes forward-forward volatilities (so a Monte Carlo would have no discretization error, only simulation error).

There is nothing to stop us using your second formula, directly differentiating call/put prices. However the Gatheral formula is much more direct and elegant and has no concern about numerical issues from far in- or out-of-the-money call prices.

Having said this, it has recently become possible to use a variant of your second formula in such a way that when you solve a PDE numerically, you exactly recover call and put prices when they have strike and expiry on the grid. In this case, the derivatives in the denominator are calculated using finite difference on the strike grid, and a slightly more complex formula is used for the finite difference to calculate the numerator. Details are here: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3530561

• I used the dupire equation, but the local volatility I got is very closed to the smoothed implied volatility. And If I used the Gatheral's formula, I got many abnormal local volatility and even negative volatility. I do have smoothed the iv surface according to Fengler's method. Aug 5, 2022 at 4:07

In the market you observe a discrete set of option prices for various strikes and expiries, so you have implied vol at this discrete set of $$(K, T)$$ points.

Then for each expiry, you need a smooth vol as a function of strike. This can be done by interpolation (e.g. cubic spline, doesn't work very well because of the "waviness" of each sub-function) or preferably by fitting a parametric function to the points via non-linear least squares minimization (e.g. SVI).

Then you need some way to interpolate vols in time. Generally linear interpolation in total variance works fine.