Awefully confused about how to write interpolation routines



I don't know how much preprocessing you had in mind
for xs and ys, like
my suggestion for ratsimp, but if you are doing
no preprocessing,  you could write a program
like this:

linterp(xs,ys, z)   that takes two vectors and a numeric
value.

Or you could maybe do  linterp(xs,ys,number_of_points, z).

And then you could write the program in C, Fortran, or ...
if you wished. There is no algebraic manipulation needed
at all.

oh, if you returned the lambda([x], stuff(x))  result, you
could get stuff(x)  or stuff(z)  just by applying it to a
symbolic argument. So they are kind closely related, and which
one you actually return is sort of arbitrary -- what do you
want?

RJF


Daniel Lakeland wrote:

> On Fri, Dec 16, 2005 at 08:48:02PM -0800, Daniel Lakeland wrote:
> 
>>Well based on the discussions earlier, I thought I understood
>>something about the "maxima way" to write an interpolation routine
>>(starting with linear interpolation). But I see from a little
>>experimentation that I don't.
>>
>>what should "linterp(xs,ys)" return? 
> 
> 
> One person has suggested that it should return an expression with a
> free variable named "x", rather than a lambda expression. Because this
> isn't a simple computation, the expression would be a block, with
> local variables and then loops. Since x would be a free variable, I
> assume simplification could take place based on recent binding of x,
> and then something like "linterp(xs,ys)" would evaluate to a number in
> certain contexts, an unevaluated block expression in other contexts
> (where x was unbound) and something else in a context where x was
> bound, but the "ys" had symbolic components.
> 
> Why this is preferred vs returning a lambda expression is not obvious
> to me (i'm just so used to scheme and common lisp that I'm not
> "getting it")
> 
> so, maybe someone could clarify why 
> 
> linterp(xs,ys) := a block expression with x unbound that computes interpolated values when evaluated in an environment where x is bound to a number; 
> 
> is preferred vs
> 
> linterp(xs,ys) := lambda([x], same block expression here);
> 
> I can see the advantage for something like the lagrange routine,
> because it returns a polynomial which could be manipulated with maxima
> routines in a "mathematical" way, but in this case, the return value
> is pretty much "computational" rather than algebraic (in other words,
> it has loops and tests and incremented variables and soforth). It
> seems to me that a "naked" expression will rarely be more useful than
> a lambda expression.
> 
> 
>