wrong sum with conditional function



On Sat, Dec 19, 2009 at 11:18 -0700, Robert Dodier wrote:
> 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.

Thank you for the answer. I tried it and I got for sum(d(k), k, 0, a);

 a 
sum (if equal(k, 0) then 0 else 1)
k=0

(with simpsum: true). I also tried simplify_sum but I got the same
result.

Best Regards

Alexandros