@Matt Wolf's answer is spot on. Sometimes though, a graphical representation helps a lot in understanding things in my opinion. I recently tried to answer a question about variance swaps. I modified the code slightly to visualize what it means to compute the fair variance swap strike.
The following screenshot (and the GIF below) plot a fictional vol surface at the bottom, and computes the Fair variance swap strike as the integral of weighted prices of out-of-the-money options over all strikes. It's just the function of weighted put and call prices at different strikes and straightforward to follow graphically (the red and orange area):
The VIX index is essentially identical to the chart above, which has the square root of the fair variance swap strike computed via integration. One might be tempted to think that this volatility number is just the par rate of a volatility swap but a vol swap would require a convexity adjustment due to Jensen’s inequality.
The intuition behind a Var swap is that a vanilla options trader, following a delta-hedging strategy, is essentially replicating the payoff of a weighted variance swap where the daily squared returns are weighted by the option’s dollar gamma, which is highest near the strike. Taking this argument one step further, a fair variance swap can be shown to equal the integral of weighted prices of out-of-the-money options over all strikes. It follows that the par rate (or variance swap strike) is defined as:
$$ K_{var} = \frac{2}{B(0,T)T} \left[ \int_0^{F(0,T)} \frac{P(K,T)}{K^2} dK + \int_{F(0,T)}^\infty \frac{C(K,T)}{K^2} dK \right] $$
where $T$ is the contract's maturity date, $B(0,T)$ the discount factor, $P(K,T)$ and $C(K,T)$ European option prices with strike $K$ and maturity $T$ and $F(0,T)$ the forward price.
These weights are being inversely proportional to squared strikes ($1/K^2$), an application of the Black Scholes closed-form formula for gamma, which ensures results in constant dollar gamma as shown below.
There are two documents from JP Morgan Variance Swaps and Just what you need to know about Variance Swaps that contain the screenshot, formulas and lots of details, with the latter being more concise. Personally, I really like Towards a Theory of Volatility Trading by Peter Carr et al.
VIX Calculation
Now, you do not have a continuum of strikes available, which is why the VIX is computed using discrete values. The white paper is very clear and even replicates the entire VIX calculation step by step (only minor details like getting the correct df are ignored).
Specifically each strike that goes into the computation (there is some filtering including only options that have a non-zero bid price and the like - exact detail are described in Cboe Volatility Index® Mathematics Methodology), is computed as
$$\frac{delta_K}{k^2} * df * Q(K_{i})$$.
- $∆𝐾_𝑖 = \frac{𝐾_{𝑖+1} − 𝐾_{𝑖−1}}{2}$ is half the difference between the adjacent strike prices on either side of strike 𝐾
- $k^2$ is strike squared
- $df$ is the discount factor (computed with minutes to expiry accuracy from constant maturity treasury rate yield curve with cubic spline interpolation to get the yield on the expiration dates)
- $Q(K_{i})$ is the mid of the options bid ask at that k (only OTM calls and puts are used, except for ATM, which uses the average of call and put).
The sum of all such values for all strikes (meeting the filtering criteria) for the near term (below 30 days) and next term (above 30 days) is combined to a 30 day weighted average. The filtering rules make the computation quite tedious though if you want to fully replicate it yourself.
Graphical example
However, we can make our life a lot easier by assuming we do have a continuum of strikes available. As mentioned, I'll express the variance strike as $\sqrt{K_{var}}\times 100$ to be consistent with the VIX index. Moreover, I assume dividends and interest rates are zero to skip discounting and to simplify the formula somewhat because ATMS = ATMF.
- The details and Julia code used below can be found in this answer. For the purpose of this answer, just remember that the VIX is the area under the weighted OTM options (Puts red / Calls orange).
- According to Black Scholes, IVOL is known and constant. This is the starting point of the GIF below (IVOL is a flat horizontal line).
- The vol surface exists mainly because there are fat tails, skewness, heteroscedasticity, jumps (crashes), and so forth. None of these real-world phenomena are featured in the Black Scholes formula. The market just developed ways to account for many of the shortcomings of Black Scholes. You can read plenty more details here.
- Adding skew (the line tilts to one side) or adding kurtosis (the curve bends upward), not only adjusts for the shortcoming in Black Scholes, but also adjusts the VIX (Fair Var Swap strike, shown in the chart title). Usually, VIX is higher, relative to ATM, the more pronounced skew and kurtosis are. That's why 1M ATM IVOL for SPX is usually lower compared to the VIX.
Making the chart interactive shows how the VIX (and Var Swap) depend on the level, it also shape of the vol surface (unfortunately imgur doesn't allow a bigger size, hence better resolution).