Subject: how can I make a variable local inside "product"?
From: van Nek
Date: Thu, 11 May 2006 16:47:50 +0200
Am 11 May 2006 um 15:31 hat Fabrizio Caruso geschrieben:
> Hi!
>
> This is either a bug or I am using the wrong command:
>
> test(n) := product(n+i,i,1,3);
> or even
> test(n) := block([i],return(product(n+i,i,1,3));
>
> behave differently on input contaning "i" and those
> not containing "i", e.g.
>
> test(n-2*k) -> (n - 2 k + 1) (n - 2 k + 2) (n - 2 k + 3)
>
> but(!!!)
> test(n-2*i) -> (n - 3) (n - 2) (n - 1)
>
>
> Is this a bug or did I do something wrong?
>
>
> Fabrizio
>
Hi Fabrizio,
this is not a question of using function product or sum or ...
it is a question of variable binding in Maxima
If you are not aware, you can create
(%i1) foo(x):=ev(x)$
(%i2) foo(x-1)=ev(x-1);
(%o2) x - 2 = x - 1
(%i3) %-x+2;
(%o3) 0 = 1
In your example I suggest
test(n) := product( n+i31962, i31962, 1, 3 )$
HTH
Volker