Lagrange Interpolating Polynomials

How This Works


This app generates the values, coefficients, and graph for a specified Lagrange interpolating polynomial. The polynomial may be specified in a variety of ways. To begin one specifies the interpolation knots, values on the t-axis at which the polynomial is to take specified values. These values may be indicated by either listing or, if they are evenly spaced, by indicating the first knot, the last knot, and the total number of knots (including first and last). Once the knots have been specified, specify the values to be interpolated at the knots. These values may be specified by listing or by specifying a function to be applied to the interpolating knots. The resulting Lagrange interpolating polynomial will have degree one less than the number than the number of knots specified and therefore will have as many coefficients as the number of knots.

If one chooses to specify the interpolated values by giving a function to interpolate and needs guidance, follow the second tab at left.

Under the fourth tab at left, one may view the coefficients of the Lagrange polynomial (rounded to three figures). One may also submit arguments to the Lagrange polynomial and interpolated function (if any) and view the resulting values. These may be downloaded as a csv with arguments in row one, Lagrange values in row two, and functional values (if any) in row three. Finally a csv file consisting of the knots (row one), interpolated values (row two), and coefficients of the Lagrange interpolating polynomial (row three) is also available for download.

Under the final tab at left, a graph of the Lagrange interpolating function is depicted (in red). If the interpolated values were generated by a function, the graph of that function is also shown (blue). Below is a link to a pdf which briefly outlines the mechanics of Lagrange interpolation.

If one chooses to specify the interpolated values by giving a function to interpolate, the rules of syntax for specification are just those for the R language: +, -, *, /, and ^ indicate addition, subtraction, multiplication, division, and exponentiation respectively and sin(t), cos(t), sqrt(t), abs(t), and exp(t) are the obvious functions.

Examples:


Example 1: Enter 'exp(-t^2/2)' (w/o quotes) to specify the function \(f(t)=e^{-t^2/2}\).


Example 2: Enter 't^3+cos(2*t)' (w/o quotes) to specify the function \(g(t)=t^3+cos(2t)\).


Example 3: Enter 'abs(2*t-3)' (w/o quotes) to specify the function \(h(t)=|2t-3|\).


Example 4: Enter 'sqrt(t^2+1)' (w/o quotes) to specify the function \(h(t)=\sqrt{t^2+1}\).


Help with mathematical functions/operations available in R may be found here:

More advanced help with statistical/mathematical functions in R is here:



Interpolant Values


          

Lagrange Polynomial Coefficients (descending order of power, rounded to three digits)


            

Inputs to the Lagrange Polynomial and Interpolant Function

Computed Values of Lagrange Polynomial:


            

Computed Values of Interpolant Function:


            
          

Lagrange Polynomial (red) and Interpolant Function (if any, blue)