lagrange_nd, a C++ code which is given a set of ND points X(*) in D-dimensional space, and constructs a family of ND Lagrange polynomials P(*)(X), associating polynomial P(i) with point X(i), such that, for 1 <= i <= ND,

        P(i)(X(i)) = 1
but, if i =/= j
        P(i)(X(j)) = 0

The library currently includes the following primary routines:

The set of ND polynomials P(*)(X) are returned as a set of three arrays:

Each value of PE(i,j) is an exponent codes which can be converted to a vector of exponents that define a monomial. For example, if we are working in spatial dimension D=3, then if PE(i,j)=13, the corresponding exponent vector is (0,2,1), so this means that the j-th term in polynomial i is

        PC(i,j) * x^0 y^2 z^1
An exponent code can be converted to an exponent vector by calling mono_unrank_grlex().


The computer code and data files described and made available on this web page are distributed under the MIT license


lagrange_nd is available in a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

LAGRANGE_INTERP_ND, a C++ code which defines and evaluates the Lagrange polynomial p(x) which interpolates a set of multivariate data, so that p(x(i)) = y(i).


SPARSE_INTERP_ND a C++ code which can be used to define a sparse interpolant to a function f(x) of a multidimensional argument.

TEST_INTERP_ND, a C++ code which defines test problems for interpolation of data z(x), depending on an M-dimensional argument.


  1. Philip Davis,
    Interpolation and Approximation,
    Dover, 1975,
    ISBN: 0-486-62495-1,
    LC: QA221.D33
  2. Tomas Sauer, Yuan Xu,
    On multivariate Lagrange interpolation,
    Mathematics of Computation,
    Volume 64, Number 211, July 1995, pages 1147-1170.

Source Code:

Last revised on 22 March 2020.