Subject: Problem with expand in lagrange interpolation
From: Stavros Macrakis
Date: Thu, 14 Jun 2007 15:06:34 -0400
On 6/14/07, Daniel Lakeland <dlakelan at street-artists.org> wrote:
>
> ... the routine
> returns a global polynomial interpolatant, as opposed to the cubic
> splines or linear interpolation ...
>
> so perhaps we could have a single routine that returns whatever form
> is requested:
>
> polyinterpol(data,form,var)... where form selects the various forms.
>
Well, if the coefficients are represented exactly (not floating point), it
is easy to convert from one form to another. And in fact it is useful to do
this with polynomials which do *not* come from interpolation. That is why I
would prefer something like this:
interpolation_polynomial( points )
and then separate routines
to_bernstein(...)
to_lagrange(...)
and perhaps also
to_bernstein_code(...)
to_lagrange_code(...)
to_taylor_code(...)
which would return a piece of Maxima code that evaluated a polynomial
efficiently in each of the different ways.
Of course, this won't work in general if the polynomials have floating-point
coefficients.
-s
PS Here is a corrected version of to_bernstein:
to_bernstein(poly,var,a,b):=
block([degree,denom,nvar],
poly: subst((var-a)/(b-a),var,poly),
poly: rat(poly,var),
denom: ratdisrep(ratdenom(poly)),
poly: ratnumer(poly),
if not freeof(var,denom)
then error("polynomials only"),
degree: hipow(poly,var),
nvar: var*(b-a)+a,
sum( binomial(degree,i)*nvar^i*(1-nvar)^(degree-i)*
sum( binomial(i,j)/binomial(degree,j)
*ratdisrep(ratcoeff(poly,var,j)),j,0,i)/denom,
i,0,degree))$