19.11 InterpolatedPolynomial

InterpolatedPolynomial( R, x, y )

InterpolatedPolynomial returns the unique polynomial of degree less than n which has value y[i] at x[i] for all i=1,...,n, where x and y must be lists of elements of the ring or field R, if such a polynomial exists. Note that the elements in x must be distinct.

    gap> x := Indeterminate(Rationals);; x.name := "x";;
    gap> p := InterpolatedPolynomial( Rationals, [1,2,3,4], [3,2,4,1] );
    (-4/3)*x^3 + (19/2)*x^2 + (-121/6)*x + 15
    gap> List( [1,2,3,4], x -> Value(p,x) );
    [ 3, 2, 4, 1 ] 
    gap> Unbind( x.name ); 

Previous Up Top Next
Index

GAP 3.4.4
April 1997