Subject: Re: automatic generation of letrule packages
From: Robert Dodier
Date: Wed, 18 May 2005 08:03:12 -0700 (PDT)
--- Allan Adler wrote:
> I'm having trouble getting Maxima to accept summations
> that depend on n in this way inside the block.
[...]
> But basically the result of C3 is that the answer is represented
> as a summation sign and an upper limit that depends on n, but 5
> hasn't been substituted for n, so it's not evaluated to give x[2].
[...]
> In gleep[9], the square of x[1] would be x[2]+x[4].
OK, it looks like the problem is that the summation isn't
getting evaluated enough. I find the following paraphrase
yields the above two expected results:
r(n) := block ([rhs: sum (x[2*i], i, 1, if evenp((n-1)/2) then
(n-1)/4 else (n-3)/4)], apply (let, [[x[1]^2, rhs], gleep]));
r(5) => x[1]^2 --> x[2]
r(9) => x[1]^2 --> x[4] + x[2]
It appears that let evaluates its first argument but quotes
the second; I believe this explains the behavior you observed.
It is something of a custom to use apply to cause evaluation
of arguments for argument-quoting functions.
Hope this helps,
Robert Dodier
__________________________________
Do you Yahoo!?
Make Yahoo! your home page
http://www.yahoo.com/r/hs