Subject: Problem with expand in lagrange interpolation
From: Stavros Macrakis
Date: Thu, 14 Jun 2007 14:20:23 -0400
On 6/14/07, Daniel Lakeland <dlakelan at street-artists.org> wrote:
>
> I spent a little time last night rewriting the lagrange routine's
> computation of the polynomial to use the newton divided differences
> form.
>
I'm not sure I understand. The interpolation polynomial (of degree n-1) on
n points is unique. There is a variety of ways of rewriting that polynomial
for various purposes and I don't see why you'd want the lagrange routine to
output anything other than the lagrange form.
On the other hand, you might want routines for converting a polynomial (any
polynomial) to the various forms, and we have some of them:
taylor(...) useful in the neighborhood of a particular point.
rat(...) tells you about its behavior for very large values.
The Bernstein form is useful for evaluating in a given range (see code
below)
Etc.
-s
/* convert any polynomial in var to the Bernstein form for the range [a,b]
*/
/* result is a formula, not a program, and not very efficient, but
demonstrates the form */
to_bernstein(poly,var,a,b):=
block([degree,denom,nvar],
poly: subst((var-a)/(b-a),var,poly),
poly: rat(poly,var),
denom: ratdenom(poly),
if not constantp(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),
i,0,degree))$