# Polynomial interpolation

Given distinct real points and real numbers , we seek a polynomial function such that for all . Such a polynomial function is a polynomial interpolant.

## Lagrange formula

To determine a polynomial interpolant given and as above, it is convenient to use Lagrange formula (first discovered by Waring):

where . Note that this is the unique polynomial of degree at most fitting through the given data points and values.

## The GUI

Running the downloadable MATLAB® code on this page opens a GUI which allows you to play with different interpolation points, always using Lagrange interpolation.

Notice that the scaling of the axes might change.

interp_GUI


In this GUI, the interpolation is made using equispaced points, Chebyshev points, and custom points.

Equispaced points : There is not much to say here. The x-coordinates of the interpolation nodes are equispaced.

Chebyshev points : These are the roots of the Chebyshev polynomial of the first kind. For a given , the Chebyshev points are given

for (the multiplicative factor of 5 is because we are working with the symmetric interval [-5,5]).

They are particularly good points since they minimise Runge's phenomenon (look at the error graphs to see this!)

Custom points : By clicking on the Custom axis, you can activate a pointer. Click on the coordinate point where you want to place the new interpolation node. There is a Reset button to clear all the custom interpolation nodes created so far.

## The interface

Edit box Function : Here you can enter a function f(x) to be interpolated. You will have to enter it using MATLAB® notation, e.g. x^2 is NOT accepted, while x.^2 is accepted. The preset function is Runge's example, namely . Once you have entered the function, press the Interpolate button to update the graphs.

Edit box No. of nodes: : Here you can enter the number of interpolation nodes. This number will affect only the interpolations done with equispaced and Chebyshev points. The preset number of nodes is 10. Once you have entered the number of nodes, press the Interpolate button to update the graphs.

Push button Interpolate : Press to update the graphs. All the graphs will show the original function in blue and the interpolation in red.

Panel Show error : Select *Equispaced if you want to see the error (in magnitude) of the interpolation with equispaced points; select Chebyshev if you want to see the (in magnitude) of the interpolation with Chebyshev points; select Custom if you want to see the error (in magnitude) of the interpolation with custom points. After you select any of the options, the error graph will automatically update. Note that while the Custom option is on, the graph of the error will update automatically every time a new custom interpolation node is added.

Push Button Reset: This button only affects the interpolation with custom points. It clears all the previous custom interpolation added.

Push button Close : Press this button to close the GUI.

## The Code

All files as .zip archive: interp_all.zip