Question: Why does sum not give a different answer when I change the vector?

See the following code

restart;
u:=Vector(1);
u[1]:=1;
x1:=sum('u[i]^i','i'=1..1);
u[1]:=2;
x2:=sum('u[i]^(i)','i'=1..1);
x3:=sum('u[i]^(i+1)','i'=1..1);

When I run x1=1 and x2=1, but x3=4. But x2 should be 2. I presume this has something to do with the fact that when sum sees u[1] it already thinks it knows what u[1] is, but when it sees u[1]^2 it recalculates.  I realize that "add" would solve the problem here, but I thought for short sums sum called add. Suggestions?

 

 

Please Wait...