If I run the following code
q: charfun(x>a);
assume(a<b);
integrate(q,x,a,b);
Maxima is able to compute the value of integral, which is b-a
, but if I run the same calculation using items from an indexed array x[i]
and x[i+1]
in place of a
and b
, as below,
q: charfun(x>x[i]);
assume(x[i]<x[i+1]);
integrate(q,x,x[i],x[i+1]);
Maxima is not able to perform the symbolic computation and returns
instead of x[i+1]-x[i]
. Is there a way to make Maxima calculate the integral?
Well, I think Maxima is getting confused that the variable of integration x
also appears in the limits of integration. If you change the variable of integration to be something else, you get the expected result, I think.
q: charfun(u>x[i]);
assume(x[i]<x[i+1]);
integrate(q,u,x[i],x[i+1]);
yields x[i+1]-x[i]
.