Subject: Re: automatic generation of letrule packages
From: Allan Adler
Date: Wed, 18 May 2005 01:24:28 -0400
Thanks for all the helpful suggestions in this thread and the one on
algebra structures.
Suppose I want to define a function L(n) which creates an algebra.
For all practical purposes, an algebra is a certain kind of letrule
package. So L(n) either returns the package or at least causes it to
be created with a name that depends on n, such as L[n] or XXXn.
So, maybe L(n) is defined something like this:
L(n):=block([u,v,w,...],
for i:1 thru n do
for j:i thru n do
apply(let,[x[i]*x[j],F(i,j,n),L[n]]));
I put it in a block since there might be a lot of other rules besides these.
The function F(i,j,n) might be somewhat general. For example, suppose that
we want x[1]^2 to equal x[1]+...+x[m] where m is the greatest integer not
exceeding n/2. I'm having trouble getting Maxima to accept summations
that depend on n in this way inside the block. For example:
(C1) r(n):=block([],
let([x[1]^2,sum(x[2*i],i,1,if evenp((n-1)/2) then (n-1)/4 else (n-3)/4)],gleep)
);
(C2) r(5);
(C3) letsimp(x[1]^2,gleep);
I've omitted the D lines since they are hard to cut and paste correctly
into email. 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]. Also, it complains
when I try to use something like gleep[n] instead of gleep, so that I
have distinct rule packages gleep[3], gleep[9], ... after executing r(3)
and r(9). In gleep[9], the square of x[1] would be x[2]+x[4].
--
Ignorantly,
Allan Adler
* Disclaimer: I am a guest and *not* a member of the MIT CSAIL. My actions and
* comments do not reflect in any way on MIT. Also, I am nowhere near Boston.