kill(all)$

programming :control when evaluation sum , version 1.0.
peter.vlasschaert@gmail.com,19/04/2019.

load packages
=============

load(lrats)$

start :session with option false .
===========================

simp:false;

control evaluation 
---------------------------
option  : simp has two : {false,true}.

definition of sum  : sm1
====================

sm1(k1,k2,k3,k4):= block([x:false],simp:x,
sum(k1,k2,k3,k4));

p1:sm1(k2^2,k,1,100);

p1a:subst([k2=k],p1);

p2:ev(p1a,nouns,simp:true);

p3:sm1(k2^2,k2,1,100);

p3a:subst([k2=l],p3);

evaluation allowed , ev 'option' : simp:true
====================================

p3b:ev(p3a,nouns,simp:true);

simplification blocked: general.
==========================

p4:simp;

definition of sum  : sm2
====================

sm2(k1,k2,k3,k4,nn):= block([x:false,s],simp:x,
s:sum(k1,k2,k3,k4),subst([k2=nn],s));

sm2: fifth arg: nn, the symbol for the summation index.
==============================================

p4:sm2(k2^2,k2,1,inf,l);

p4a:ev(p4,nouns,simp:true);

how to use  : definition 'sm2'
-------------------------------------------

general : syntax 'sm2'
==================

sm2(f(k2),k2,a,b,symbol you like)
example : 'above' , symbol you like ,'l'
a: integer , minf,inf.
b: integer , minf,inf.
rem : inf      =>  ∞
          minf   => -∞

p4b:simp;

k2;

p5:sm2(k2^2,k2,1,100,v);

sm2(f(k2),k2,a,b,symbol you like)
example : 'above' , symbol you like ,'v'

p5a:simp;

p5b:ev(p5,nouns,simp:true);

p5c:simp;

example :

p6:d*sm2(k2^5+3*k2,k2,minf,inf,w);

assume(d>0);

p6a:intosum(p6),ratsimp;

assume(e>0);

p6b:e*sm2(k2^7+3*k2,k2,minf,inf,w);

p6c:intosum(p6b),ratsimp;

simp;

rem :sumcontract when  , simp:true.

p7:ev(sumcontract(p6a+p6c),simp:true);

p7a:ev(sumcontract(p6+p6b),simp:true);

how to combine :two summation.
============================

steps :

rem :  1e) step  simp :true
            2e) step  intosum
            3e) step  ratsimp
            4e) step  sumcontract  : 'two summation', when allowed.

====================================================
see : p7  , good ,example  1e),2e),3e),4e)
see : p7a, bad   ,example   1e),3e),4e)       
====================================================        