Numerical Methods

Outline

Introduction

Linear
Equations

Interpolation

Numerical
Solutions

Computer
Measurement

      

Interpolation of data sets

If a function is only known at a discrete set of data points $(x_{i}, y_{i})$, interpolation can be used to estimate the value of that function at values of $x$ not included in the data. An interpolation function $I(x)$ passes through the points of a discrete data set,

\begin{equation} I(x_{i})=y_{i}. \end{equation}

Usually we desire a function that smoothly connects the data point. One possibility is to use the polynomial of the least degree that passes through all of the points. Lagrange showed that this polynomial function is given by,

\[ \begin{equation} I(x) = \sum\limits_{k=1}^{N}y_k\prod\limits_{i=1\,(i\ne k)}^{N}\frac{x-x_i}{x_k-x_i}. \end{equation} \]

The app below calculates the polynomial fit through the series of points given in the text box. For data set 1, the interpolation function fits the data set well. However for data set 2, the interpolation function deviates far from the points even though it passes through every point. Try changing a data point in the data to see how the interpolation function changes.

 $x_i$ $y_i$

$y$

$x$

Code that calculates this polynomial is shown below.


lagrange_poly.py

For the polynomial fit, it is the higher order polynomials that sometimes causes the interpolation function to deviate quite far from the data. To avoid this problem, the order of the polynomials is limited. Two commonly used approaches are linear interpolation and cubic splines. These methods of interpolation are discussed in the next two sections.