On Mon, Dec 1, 2008 at 3:08 PM, Edwin Woollett <woollett at charter.net> wrote:
> I am trying to make a program interchange the
> order of summation and integration by supplying
> a noun form.
Maybe the following helps. By the way, maybe declare(integrate, linear)
ought to cause integrate to commute with sum when it's a finite sum;
it doesn't at present if I;m not mistaken.
matchdeclare ([aa, bb, cc, dd, xx, yy, zz], all);
simp : false;
'integrate ('sum (aa, bb, cc, dd), xx, yy, zz);
defrule (r1, ''%, buildq ([aa, bb, cc, dd, xx, yy, zz],
'sum ('integrate (aa, xx, yy, zz), bb, cc, dd)));
simp : true;
The buildq stuff is needed to make this work with sum's
peculiar evaluation of arguments; that causes trouble often
enough that I think we should seriously consider changing
sum to evaluate its arguments in an ordinary way.
OK, now apply this rule to a particular example ...
foo : 'integrate ('sum (x^n, n, 1, 3), x, 0, 1);
=> 'integrate('sum(x^n,n,1,3),x,0,1)
bar : apply1 (foo, r1);
=> 'sum('integrate(x^n,x,0,1),n,1,3)
bar, integrate;
=> 'sum(1/(n+1),n,1,3)
bar, sum;
=> 'integrate(x^3,x,0,1)+'integrate(x^2,x,0,1)+'integrate(x,x,0,1)
bar, nouns;
=> 13/12
Hope I've understood what you're trying to achieve.
best
Robert Dodier