On 12/19/09, Alexandros Droseltis <ml-maxima at alex-droseltis.com> wrote:
> (%i1) d(k) := if k=0 then 0 else 1;
> (%o1) d(k) := if k = 0 then 0 else 1
> (%i2) assume(a>0);
> (%o2) [a > 0]
> (%i3) sum(d(k), k, 0, a);
> (%o3) a + 1
> (%i4)
>
> How comes this +1 in the result?
This is actually a consequence of the behavior of "=".
a = b is true when a and b are identical expressions,
while equal(a, b) is true when a and b are equivalent.
e.g. is(x*(x + 1) = x^2 + x) => false (not identical)
while is(equal(x*(x + 1), x^2 + x)) => true (equivalent).
Try putting if equal(k, 0) ... in your function.
I think you'll get a different result.
best
Robert Dodier