Subject: how can I make a variable local inside "product"?
From: Albert Reiner
Date: 11 May 2006 16:51:58 +0200
[Fabrizio Caruso <caruso at posso.dm.unipi.it>, Thu, 11 May 2006 15:31:03 +0200 (CEST)]:
> test(n) := product(n+i,i,1,3);
...
> test(n-2*i) -> (n - 3) (n - 2) (n - 1)
>
>
> Is this a bug or did I do something wrong?
I don't know if it is a bug, but I do not see this behavior:
,----
| (%i1) t1(n) := product(n+i,i,1,3) $
|
| (%i2) t1(j);
|
| (%o2) (j + 1) (j + 2) (j + 3)
| (%i3) t1(i);
|
| (%o3) (i + 1) (i + 2) (i + 3)
| (%i4) t1(n-2*i);
|
| (%o4) (n - 2 i + 1) (n - 2 i + 2) (n - 2 i + 3)
`----
This is on:
,----
| Maxima version: 5.9.2
| Maxima build date: 14:19 12/26/2005
| host type: i686-redhat-linux-gnu
| lisp-implementation-type: CMU Common Lisp
| lisp-implementation-version: Snapshot 2005-11 (19C)
`----
As a workaround you might try something like ... := block([m],
subst(n, m, product(m+1, ...))) or maybe use a gensym instead of i.
Albert.