Next: , Previous: , Up: Algebra   [Contents][Index]


2.5 Interpolation

Command: interp mat
Command: interp vec1 vec2 …

The only argument, mat, must be an array having at least one row of two expressions: [[x1,y1],[x2,y2],…]. It is an error if there are any duplicates in the first column of the second argument,

interp returns a polynomial function poly(@1) such that mat[1,2]=poly(mat[1,1]), mat[2,2]=poly(mat[2,1]), etc.

There is a variant of the interp command that takes multiple vector arguments instead of a matrix. These vectors represent points to be interpolated over. The same constraints apply as in the matrix version. All the variants of the interpolation procedure described later have both these forms.

e9 : interp([[2, 3], [0, -1]]);

e9 : lambda([@1], -1 + 2 @1)

e10 : interp([[2, 3], [1, z]]);

e10 : lambda([@1], -3 + 2 z + (3 - z) @1)

e11 : interp([2, 3], [y, z]);

                  3 y - 2 z + (-3 + z) @1
e11 : lambda([@1], -----------------------)
                          -2 + y
Command: interp.lagrange mat
Command: interp.lagrange vec1 vec2 …

This is the same as the interp command.

Command: interp.newton mat
Command: interp.newton vec1 vec2 …

This is similar to interp command with an added option of including derivative values when defining points. The same constraints apply as in interp. You can choose to specify some number of derivatives for each point. That number does not have to be the same for all points.

e0 : interp.newton([-1, 0], [0, 1], [1, 0]);

                       2
e0: lambda([@1], 1 - @1 )

e1 : interp.newton([-1, 0], [0, 1, 0, 20], [1, 0]);

                          2        4
e1: lambda([@1], 1 + 10 @1  - 11 @1 )

e2 : interp.newton([-1, 0], [0, 1, 0, a], [1, 0]);

                         2              4
                 2 + a @1  + (-2 - a) @1
e2: lambda([@1], ------------------------)
                            2
Command: interp.neville mat
Command: interp.neville vec1 vec2 …

The same as interp in its functionality, but uses newtons form when constructing the polynomial.


Next: Factoring, Previous: Polynomials, Up: Algebra   [Contents][Index]