Problem with expand in lagrange interpolation



On Thu, Jun 14, 2007 at 09:42:30AM -0700, Richard Fateman wrote:
> Because of repeated subexpressions, such an expression would be bulky and
> slow to compute (take n! time instead of n^2, I think).
> A block  (or as robert suggests, a lambda([x], block(....))  )  would be
> better, I think

It certainly looks n^2 rather than n! but I'm not sure what might
happen in terms of resimplification or whatever other internal
computations maxima might do deep inside itself.

I agree that the block form (or lambda(block())) will be faster and
neater. However, here's an example of a computation that I used
lagrange polynomials on recently which might be difficult with a block
form:

To solve for a fluid flow problem, I used lagrange interpolation
through between 7 and 15 points (eventually settling on about 10) for
two coupled functions (velocity and surface height), using mnewton to
vary the y value of the interpolation points to set the collocation
residual to zero. I then used the resultant polynomials to graph the
fluid height and compute some properties of the flow.

At the time I was concerned about numerical stability but decided that
it was not severely affecting the results after experimentation,
especially for only 8 to 10 terms. As the number of terms increases,
the computation obviously becomes untenable in this form. 

Doing the mnewton iteration in rational arithmetic was far too slow. 

I believe that a block form for the polynomial would make this kind of
mnewton iteration relatively difficult to do but I'm not sure. I don't
really know how well mnewton would handle a block expression vs a
polynomial, and I think the issue extends beyond mnewton to many other
procedures (such as lbfgs and soforth).

Food for thought...


-- 
Daniel Lakeland
dlakelan at street-artists.org
http://www.street-artists.org/~dlakelan