Question: sum versus add

Question:sum versus add

fbackelj 271 Maple
Hello, suppose you have the following function which gives 1 if both its arguments are even: G := (i,j) -> if is(i,even) and is(j,even) then 1; else 0; end if; Then what is the difference between these two statements: sum( sum( G(i,j), i=0..5 ), j=0..5 ); add( add( G(i,j), i=0..5 ), j=0..5 ); The first one gives 0 and no sum is actually computed (you can see this by adding print(i) and print(j) statements in the body of G). The second one gives the correct result, namely 9. How come i is not replaced in sum? -- Thanks for any reply, Franky.
Please Wait...