polynomial-0.5: Polynomials

Math.Polynomial.Bernstein

Synopsis

# Documentation

bernstein :: [[Poly Integer]]Source

The Bernstein basis polynomials. The `n`th inner list is a basis for the polynomials of order `n` or lower. The `n`th 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 -> bSource

`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 -> aSource

Evaluate a polynomial given as a list of `n` coefficients for the `n`th 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`).