Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 15

Polynomial Interpolation: Stability and Runge's Phenomenon

Recommended resources

Introduction

In our previous lesson, we explored linear interpolation as a way to create a continuous spot rate curve from discrete bootstrapped points. While simple and intuitive, we discovered its significant flaw: it produces a discontinuous forward rate curve, which is economically implausible and problematic for pricing and risk management. This flaw stems from the abrupt changes in slope at each data point, or "knot."

The natural next thought is to use a smoother function. Instead of connecting the dots with separate straight lines (degree-1 polynomials), why not fit a single, higher-degree polynomial through all the data points? A single polynomial is infinitely differentiable, guaranteeing that the spot curve, forward curve, and all their derivatives are continuous. Today, we will explore this approach. Your objective is to apply polynomial interpolation and, crucially, to identify its own severe limitation: a tendency toward instability and wild oscillations, a phenomenon known as Runge's phenomenon.


1. The Theory of Global Polynomial Interpolation

The fundamental theorem of polynomial interpolation states that for a given set of data points with unique maturities , there exists a unique polynomial of degree at most that passes through all of them.

This polynomial can be written in its standard form:

Finding the interpolating polynomial means solving for the coefficients . This can be done by setting up a system of linear equations, where each equation is . While this is solvable, it often involves inverting a Vandermonde matrix, a process known to be numerically unstable for high degrees.

A more stable and theoretically elegant approach is to use a different basis, like the one in Lagrange interpolation. To get a formal understanding of the theory and the mechanics of Lagrange interpolation, please read the following sections from the ACME Labs text on the topic.

Polynomial Interpolation

This resource from Brigham Young University's ACME Labs provides a mathematically rigorous introduction to polynomial interpolation.

Read the introduction and the section on Lagrange interpolation. Focus on these key ideas: The uniqueness property: For a given set of points, there is one and only one interpolating polynomial of degree n. The construction of Lagrange basis functions L_j(x) in Equation (1). Understand their property of being 1 at x_j and 0 at all other x_i. Equation (2): See how the final polynomial p(x) is constructed as a linear combination of these basis functions. You don't need to memorize the formula, but understand the principle. The important note about numerical instability: The text wisely advises against explicitly computing the coefficients of the expanded polynomial, which is a crucial point for practical implementation.


2. Implementation with Python

Fortunately, we don't need to implement Lagrange interpolation from scratch. Modern numerical libraries like NumPy provide robust tools for fitting polynomials. We will use the numpy.polynomial.Polynomial class, which handles the underlying numerical complexities efficiently.

Let's apply this to the same bootstrapped curve from our previous lesson.

import numpy as np
import matplotlib.pyplot as plt




# --- Data from previous lesson ---
bootstrapped_curve = {
    0.5: 0.010,
    1.0: 0.014,
    1.5: 0.017,
    2.0: 0.022
}
maturities = np.array(list(bootstrapped_curve.keys()))
rates = np.array(list(bootstrapped_curve.values()))




# --- Fit a single polynomial to the data ---
# For n+1=4 points, we fit a degree n=3 polynomial
degree = len(maturities) - 1
spot_curve_poly = np.polynomial.Polynomial.fit(maturities, rates, degree)




# --- Define the forward rate curve ---
# f(t) = d/dt [r(t)*t] = r(t) + t * r'(t)
# Since r(t) is our polynomial, r'(t) is its derivative.
spot_curve_poly_deriv = spot_curve_poly.deriv()

def forward_rate_poly(t):
    return spot_curve_poly(t) + t * spot_curve_poly_deriv(t)




# --- Visualization ---
# Create a fine grid of maturities for a smooth plot
t_continuous = np.linspace(min(maturities), max(maturities), 200)
r_continuous_poly = spot_curve_poly(t_continuous)
f_continuous_poly = forward_rate_poly(t_continuous)




# Plotting
plt.style.use('seaborn-v0_8-whitegrid')
fig, ax = plt.subplots(figsize=(10, 6))

ax.plot(t_continuous, r_continuous_poly, label='Polynomial Spot Curve (r(t))', color='blue')
ax.plot(t_continuous, f_continuous_poly, label='Polynomial Forward Curve (f(t))', color='green', linestyle='--')
ax.scatter(maturities, rates, color='red', zorder=5, label='Original Data Points')

ax.set_title('Spot and Forward Curves from Polynomial Interpolation')
ax.set_xlabel('Maturity (Years)')
ax.set_ylabel('Rate (Continuous Compounding)')
ax.legend()
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda y, _: '{:.2%}'.format(y)))
plt.show()




# Print the polynomial coefficients (from highest degree to lowest)
print("Polynomial Coefficients (c3, c2, c1, c0):", spot_curve_poly.convert().coef)

When you run this code, you'll see that both the spot curve and the forward curve are perfectly smooth. It appears we have solved the discontinuity problem of linear interpolation. The polynomial passes through all our points, and its derivatives are continuous everywhere. So, is this the solution?


3. The Instability of High-Degree Polynomials: Runge's Phenomenon

The success with four data points is misleading. The stability of polynomial interpolation deteriorates rapidly as the number of points (and thus the degree of the polynomial) increases. This leads to a problem known as Runge's phenomenon, where the interpolating polynomial exhibits wild oscillations between the data points, especially near the ends of the interval.

Runge's Phenomenon Illustration
This graph illustrates Runge's phenomenon using the function \(f(x) = 1/(1+25x^2)\). As the degree of the interpolating polynomial increases from 5 to 9, the oscillations near the endpoints (-1 and 1) become dramatically worse, deviating significantly from the true function.

This isn't just a theoretical curiosity; it has disastrous practical consequences for yield curve construction. A real-world yield curve has many data points (e.g., 1-month, 3-month, 6-month, 1-year, ..., 30-year). Fitting a single high-degree polynomial to this data is highly likely to produce absurd results.

To see this in action, let's watch a short video that fits a simple cubic polynomial to actual US Treasury data. While a cubic polynomial is low-degree, the video clearly shows how it fails to capture the overall shape of the yield curve, even predicting nonsensical negative rates at longer maturities.

Fit Treasury yield curve with cubic polynomial

This video from Bionic Turtle demonstrates fitting a single cubic polynomial to a Treasury yield curve in Excel.

Watch the entire video, but pay close attention to these moments: The motivation: We have discrete yield data and need to interpolate the gaps. The function: A simple cubic polynomial R(t) = r_0 + at + bt^2 + ct^3. The critical failure: The fitted polynomial does a decent job for short-to-medium maturities but then "breaks down" and predicts negative rates for longer maturities. This is a clear example of polynomial instability.

The video concludes by suggesting a piecewise cubic polynomial, which is a preview of our next lesson on splines. Before we get there, let's solidify our understanding of why a single, global polynomial fails.

This instability is a fundamental property of using high-degree polynomials with evenly spaced points. The following resource provides a more formal discussion of this issue.

Polynomial Interpolation

Let's return to the ACME Labs resource.

Please read the sections titled Barycentric Lagrange interpolation and Chebyshev Interpolation, stopping at the heading "Chebyshev Nodes". As you read, focus on: The stated drawbacks of Lagrange interpolation: O(n^2) complexity and, more importantly, its instability. The explicit definition of Runge's phenomenon as the increase in error as more (poorly chosen) points are added. The reference to Fig. 1 in the text, which shows the oscillations getting worse as n increases. This is the same phenomenon seen in the image LINK above.

The resource goes on to discuss Chebyshev nodes as a way to mitigate Runge's phenomenon, which is a key technique in numerical analysis. However, for yield curve construction, the financial industry has largely converged on a different solution that offers more direct control and economic intuition: splines.


Conclusion

In this lesson, we attempted to remedy the shortcomings of linear interpolation by using a single, global polynomial. While this approach theoretically guarantees a smooth spot and forward curve, we've demonstrated through theory, visualizations, and a practical example that it is not a viable solution.

Key Takeaways:

  • Global Polynomial Interpolation: A single polynomial of degree can be fitted perfectly through data points, producing a spot curve that is infinitely differentiable.
  • Apparent Advantage: This method yields a smooth, continuous forward rate curve , solving the main issue of linear interpolation.
  • Fatal Flaw (Runge's Phenomenon): As the number of data points increases, high-degree polynomials become extremely unstable, exhibiting wild oscillations between and beyond the data points. This leads to economically absurd results, such as predicting negative long-term yields.

We have found ourselves at an impasse: linear interpolation is too rigid (not smooth), while high-degree polynomial interpolation is too flexible (unstable). We need a method that combines the best of both worlds: local stability and sufficient smoothness. This leads us directly to our next topic, cubic splines, which construct the curve from a series of piecewise cubic polynomials that are smoothly joined together. This approach has become a cornerstone of modern yield curve modeling.