Safe Haskell | None |
---|---|
Language | Haskell98 |
- polyInterp :: Fractional a => [(a, a)] -> a -> a
- neville :: Fractional a => [(a, a)] -> a -> [[a]]
- nevilleDiffs :: Fractional a => [(a, a)] -> a -> [[(a, a)]]
- iterativePolyFit :: (Fractional a, Eq a) => [(a, a)] -> Poly a
- lagrangePolyFit :: (Fractional a, Eq a) => [(a, a)] -> Poly a
Documentation
polyInterp :: Fractional a => [(a, a)] -> a -> a Source #
Evaluate a polynomial passing through the specified set of points. The order of the interpolating polynomial will (at most) be one less than the number of points given.
neville :: Fractional a => [(a, a)] -> a -> [[a]] Source #
Computes the tableau generated by Neville's algorithm. Each successive row of the table is a list of interpolants one order higher than the previous, using a range of input points starting at the same position in the input list as the interpolant's position in the output list.
nevilleDiffs :: Fractional a => [(a, a)] -> a -> [[(a, a)]] Source #
Computes the tableau generated by a modified form of Neville's algorithm described in Numerical Recipes, Ch. 3, Sec. 2, which records the differences between interpolants at each level. Each pair (c,d) is the amount to add to the previous level's interpolant at either the same or the subsequent position (respectively) in order to obtain the new level's interpolant. Mathematically, either sum yields the same value, but due to numerical errors they may differ slightly, and some "paths" through the table may yield more accurate final results than others.
iterativePolyFit :: (Fractional a, Eq a) => [(a, a)] -> Poly a Source #
Fit a polynomial to a set of points by iteratively evaluating the
interpolated polynomial (using polyInterp
) at 0 to establish the
constant coefficient and reducing the polynomial by subtracting that
coefficient from all y's and dividing by their corresponding x's.
Slower than lagrangePolyFit
but stable under different sets of
conditions.
Note that computing the coefficients of a fitting polynomial is an
inherently ill-conditioned problem. In most cases it is both faster and
more accurate to use polyInterp
or nevilleDiffs
instead of evaluating
a fitted polynomial.
lagrangePolyFit :: (Fractional a, Eq a) => [(a, a)] -> Poly a Source #
Fit a polynomial to a set of points using barycentric Lagrange polynomials.
Note that computing the coefficients of a fitting polynomial is an
inherently ill-conditioned problem. In most cases it is both faster and
more accurate to use polyInterp
or nevilleDiffs
instead of evaluating
a fitted polynomial.