开发者

How to substract two Sums in Maple

I've got two sequences with variable boundaries like

> a:=Sum(x(i),i=n..m);
> b:=Sum(x(i),i=开发者_JS百科n-1..m+1);

n and m are arbitrary natural numbers and obviously m>n.

I want to substract a from b and see how Maple simplifies the expression to

> b-a;
x(n-1)+x(m+1);

Is it possible in Maple or in another CAS?


You might do it by using a temporary object,and then acting in two stages.

a:=Sum(x(i),i=n..m):
b:=Sum(x(i),i=n-1..m+1):

temp := Sum(x(i),i=op(1,rhs(op(2,a)))..op(2,rhs(op(2,b))));
                       m + 1     
                       -----     
                        \        
                         )       
                        /    x(i)
                       -----     
                       i = n    

value( combine(b-temp) + combine(temp-a) );
                  x(n - 1) + x(m + 1)

Or you might put that into a procedure.

combminus:=proc(s::specfunc(anything,Sum),t::specfunc(anything,Sum))
   local temp;
   if op(1,s) = op(1,t) then
      temp:=Sum(op(1,s),i=op(1,rhs(op(2,s)))..op(2,rhs(op(2,t))));
      value(combine(s-temp)+combine(temp-t));
   else
      s-t;
   end if;
end proc:

combminus(b, a);
                  x(n - 1) + x(m + 1)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜