Subject: how can I make a variable local inside "product"?
From: Robert Dodier
Date: Thu, 11 May 2006 09:40:06 -0600
On 5/11/06, Stavros Macrakis <macrakis at gmail.com> wrote:
> It appears that the new code does *two* evaluations of the summand. This is
> bound to lead to problems like this.... I thought we had discussed this a
> long time ago, and in fact discussed this particular kind of problem.
Yes, we did discuss it.
Here is the code that computes the each term in a finite sum/product,
lines 439 ff in src/asum.lisp.
(let*
((foo (mbinding (lind l*i) (meval expr)))
(bar (subst-if-not-freeof *i ind foo)))
bar)
expr = summand/productand (not yet evaluated),
ind = index variable, lind = index variable in a list,
*i = particular value of index, l*i = particular value of index in a list.
subst-if-not-freeof replaces instances of the index variable
by the particular value of the index.
In this case, (meval expr) => an expression containing $i .
Then subst-if-not-freeof replaces $i with 1, 2, and 3,
in succession.
> For better or worse, Maxima semantics makes it the case that
> eval(eval(<expr>)) is NOT the same thing as eval(<expr>).
Yes, as it should be.
Robert