Dr. Kevin G. TeBeest
Assoc. Prof. of Mathematics
Kettering University
First load the library of commands called CurveFitting as it contains the command PolynomialInterpolation that we need.
> | with( CurveFitting ) : |
> | points := [ [ 2, 11 ] , [ 0, 3 ] , [ 1, 5 ] , [ 3, 9] ] ; ( the structure is:   [ [x0, y0] , [x1, y1] , [x2, y2] , . . . , [xn, yn] ] ) |
> | P := unapply( PolynomialInterpolation( points, x ), x ) ; |
> | P( –2 ) ; |
> | P( 0 ) ; |
> | P( 1 ) ; |
> | P( 3 ) ; |
> | convert( P(x) , horner ) ; |
> | plot( P(x) , x = –3.0 .. 4.0 , thickness = 3 , color = blue ) ; |