polynomial-0.7.3: Polynomials

Safe HaskellNone
LanguageHaskell98

Math.Polynomial.Bernstein

Synopsis

Documentation

bernstein :: [[Poly Integer]] Source #

The Bernstein basis polynomials. The nth inner list is a basis for the polynomials of order n or lower. The nth basis consists of n polynomials of order n which sum to 1, and have roots of varying multiplicities at 0 and 1.

evalBernstein :: (Integral a, Num b) => a -> a -> b -> b Source #

evalBernstein n v x evaluates the v'th Bernstein polynomial of order n at the point x.

bernsteinFit :: (Fractional b, Integral a) => a -> (b -> b) -> [b] Source #

bernsteinFit n f: Approximate a function f as a linear combination of Bernstein polynomials of order n. This approximation converges slowly but uniformly to f on the interval [0,1].

evalBernsteinSeries :: Num a => [a] -> a -> a Source #

Evaluate a polynomial given as a list of n coefficients for the nth Bernstein basis. Roughly:

evalBernsteinSeries cs = sum (zipWith scalePoly cs (bernstein !! (length cs - 1)))

deCasteljau :: Num a => [a] -> a -> [[a]] Source #

de Casteljau's algorithm, returning the whole tableau. Used both for evaluating and splitting polynomials in Bernstein form.

splitBernsteinSeries :: Num a => [a] -> a -> ([a], [a]) Source #

Given a polynomial in Bernstein form (that is, a list of coefficients for a basis set from bernstein, such as is returned by bernsteinFit) and a parameter value x, split the polynomial into two halves, mapping [0,x] and [x,1] respectively onto [0,1].

A typical use for this operation would be to split a Bezier curve (inserting a new knot at x).