# LAGRANGE_BASIS_DISPLAY Display Basis Functions for Lagrange Interpolation

LAGRANGE_BASIS_DISPLAY is a MATLAB program which displays the basis functions associated with any set of interpolation points to be used for Lagrange interpolation.

The Lagrange interpolating polynomial to a set of m+1 data pairs (xi,yi) can be represented as

```        p(x) = sum ( 1 <= i <= m + 1 ) yi * l(i,x)
```
Each function l(i,x) is a Lagrange basis function associated with the set of x data values. Each l(i,x) is a polynomial of degree m, which is 1 at node xi and zero at the other nodes. Moreover, there is an explicit formula:
```        l(i,x) = product ( 1 <= j <= m + 1, j /= i ) ( x  - xj )
/ product ( 1 <= j <= m + 1, j /= i ) ( xi - xj )
```
Thus the interpolating polynomial can be represented as a linear combination of the Lagrange basis functions, and the coefficients are simply the data values yi.

For a given set of m+1 data pairs (xi,yi), you may also define the same interpolating polynomial using a Vandermonde matrix; this approach essentially uses the monomials 1, x, x^2, ..., x^m as the basis functions. The unknown polynomial coefficients c must be determined by forming and solving the Vandermonde system; not only is this method more costly, but this linear system is numerically ill-conditioned, so that the resulting answers can be unreliable.

### Languages:

LAGRANGE_BASIS_DISPLAY is available in a MATLAB version.

### Related Data and Programs:

LAGRANGE_INTERP_1D, a MATLAB library which defines and evaluates the Lagrange polynomial p(x) which interpolates a set of data, so that p(x(i)) = y(i).

VANDERMONDE_INTERP_1D, a MATLAB library which finds a polynomial interpolant to data y(x) of a 1D argument, by setting up and solving a linear system for the polynomial coefficients, involving the Vandermonde matrix.

### Reference:

1. Kendall Atkinson,
An Introduction to Numerical Analysis,
Prentice Hall, 1989,
ISBN: 0471624896,
LC: QA297.A94.1989.
2. Philip Davis,
Interpolation and Approximation,
Dover, 1975,
ISBN: 0-486-62495-1,
LC: QA221.D33
3. David Kahaner, Cleve Moler, Steven Nash,
Numerical Methods and Software,
Prentice Hall, 1989,
ISBN: 0-13-627258-4,
LC: TA345.K34.

### Examples and Tests:

Plots made by the test include:

• lagrange_10_chebyshev.png, the Lagrange basis functions of degree 10, for the Chebyshev points on [-1,+1].
• lagrange_10_evem.png, the Lagrange basis functions of degree 10, for evenly-spaced points on [0,+1].
• standard_10.png, the standard monomial basis functions up to degree 10, for evenly-spaced points on [0,+1].

You can go up one level to the MATLAB source codes.

Last revised on 06 August 2012.