Question: Summation of function with "if" in definition seems impossible

Hello,

 

this problem has been bugging me for months. I am defining functions with "if" in their definition.  These functions seem to be well defined, without any problem. Then I do sum and something goes wrong.  I have tried to isolate the problem to give you an example:

 

> f := proc (i) if 0 < i then return i else return -i end if end proc;
proc(i)  ...  end;
> f(-1); f(0); f(1);
                                      1
                                      0
                                      1
> sum(f(t), t = -2 .. 2);
Error, (in f) cannot determine if this expression is true or false: 0 < t
> sum(f(i), i = -2 .. 2);
Error, (in f) cannot determine if this expression is true or false: 0 < i
 

So as you can see, using the function f is not a problem. 

But using it in a sum is a problem.  It defies logic in my opinion.

Can anyone shed some light on this? Can I do something about it?

Many thanks!

Please Wait...