NAME

Math::Interpolate - Interpolation of data into a polynomial.

SYNOPSIS

use Math::Interpolate qw(interpolate);

my $polynomial = interpolate(1 => 5, 2 => 12, 3 => 6);

DESCRIPTION

Given a set of pairs of x and y values, interpolate will return a polynomial which interpolates those values. The data points are supplied as a list of alternating x and y values.

The degree of the resulting polynomial will be one less than the number of pairs, e.g. the polynomial in the synopsis will be of degree 2.

The interpolation is done using Lagrange's formula and the implementation runs in O(n^2), where n is the number of pairs supplied to interpolate.

CAVEAT

Observe that it is a bad idea to use interpolation for extrapolation, i.e. if you are interpolating a polynomial for x-values in the range 0 to 10, then you may get terrible results if you try to predict y-values outside this range. This is true especially if the true function is not a polynomial.

DEPENDENCIES

The package Math::Polynomial is required, this module is distributed together with the Math::Polynomial package since is is quite small.

COPYRIGHT

Copyright (C) 1997 Matz Kindahl. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.