From a Price Back to a Volatility
Given a quoted price, the volatility that makes the formula return it is the implied volatility; the engine finds it by a root search because the price rises with volatility.
The question
So far the volatility was an input and the price the output. Turn it round: a call is quoted at 9.00, a made-up number, and the volatility is unknown. Which volatility makes the formula return 9.00? That volatility is called the implied volatility of the quote.
The formula can be run forwards but has no closed form backwards. The engine searches for the answer, and it can, because in this formula the price of an option rises as the volatility rises.
Work it by hand
Use the example of the book: spot 100, strike 105, rate 0.05, one year. At a volatility of 0.2 the call is 8.02 and at 0.3 it is 11.98, from the last lesson. The quote 9.00 lies between them, so the implied volatility lies between 0.2 and 0.3.
A straight line between the two prices puts 9.00 at 0.2 plus 0.1 times (9.00 minus 8.02) over (11.98 minus 8.02), which is 0.2247. The price curve is not a straight line, so this is a guess, and it happens to be close. The engine's answer is exact to many digits.
Run it
The program prices the call at 23 volatilities, from 0.05 to 0.60 in steps of 0.025, and asks the engine for the implied volatility of the quote. Line 1 builds the model with a volatility of 0.2 only as a starting value: the search replaces it. The loop of lines 5 to 9 builds the curve of price against volatility with with_vol in line 8. Line 10 calls calibration.implied_vol, and line 14 returns it in whole basis points.

let m = model.black_scholes(spot, rate, 0.0, 0.2);
let option = instrument.european_call(strike, float(years));
let engine = pricing.analytic();
let xs = float_list(); let ys = float_list();
for (k in range(0, 23)) {
let v = 0.05 + 0.025 * float(k);
xs.add(lmf.round(v, 3));
ys.add(lmf.round(pricing.price(option, m.with_vol(v), engine).price(), 4));
}
let root = calibration.implied_vol(option, m, engine, quote);
lmcode_return_put("vols", xs);
lmcode_return_put("prices", ys);
lmcode_return_put("root", lmf.round(root, 6));
let answer = int(math_round(lmf.round(root, 4) * 10000.0));
{
"answer": 2247,
"vols": [
0.05,
0.075,
0.1,
0.125,
0.15,
0.175,
0.2,
0.225,
0.25,
0.275,
0.3,
0.325,
0.35,
0.375,
0.4,
0.425,
0.45,
0.475,
0.5,
0.525,
0.55,
0.575,
0.6
],
"prices": [
2.0543,
3.0504,
4.0461,
5.0412,
6.0356,
7.029,
8.0214,
9.0125,
10.0022,
10.9904,
11.9769,
12.9615,
13.9442,
14.9247,
15.9029,
16.8787,
17.8518,
18.8223,
19.7898,
20.7544,
21.7158,
22.6739,
23.6285
],
"root": 0.224685
}The picture marks the quote on the curve at the volatility the engine found. You can change the spot, the strike, the rate, the quote and the years, a whole number of 1 or more. A quote that no volatility reaches stops line 10, for example a quote of 0 with "price 0 is outside the range reachable with volatility in [0.0001, 5]".
A call is worth at least spot minus the discounted strike (0.1209 here) and less than the spot, so with these inputs 0.12 and 99 stop it, and so does the quote 9.00 once the years are 5: the discounted strike is then 81.8 and the lower limit 18.2.
Your turn
A put is quoted at quote, a made-up number. The program below is meant to return its implied volatility in whole basis points, one basis point being 0.0001, for spot, strike, rate and years, with no dividend. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on four others.

let m = model.black_scholes(spot, rate, 0.0, 0.2);
let option = instrument.european_call(strike, float(years));
let vol = calibration.implied_vol(option, m, pricing.analytic(), quote);
let answer = int(math_round(lmf.round(vol, 4) * 10000.0));
{
"answer": 3760
}A European put is quoted at quote, a made-up number. Return its implied volatility in whole basis points, one basis point being 0.0001: the volatility at which the Black-Scholes price of the put (no dividend) equals the quote.
Read the result carefully
An implied volatility is the model's parameter backed out of one price. It is not a measurement of how much the price will move and not a forecast. The same model gives different implied volatilities for different options on the same stock, as the last lesson of this chapter shows.
The root search needs the price to rise with the volatility and the quote to be reachable. The quotes are made up, and the page describes a model and is not investment advice.
Recap
- The implied volatility of a quote is the volatility at which the formula returns it.
- The engine finds it by a root search,
calibration.implied_vol. - It needs
pricing.analytic(); the starting volatility of the model is not the answer. - The result depends on the quote, the option and the inputs of the model.