kill(all)$

maxima : programming : Implicit Sum (with kron_delta) and linear functions,version 1.0
peter.vlasschaert@gmail.com,02/06/2022

ref:
https://def.fe.up.pt/pipermail/maxima-discuss/2008/023513.html
rem :
the commands `tellsimp? and `tellsimpafter? only work after `matchdeclare? "see: ref"

→kron_delta(,) 
---------------------

matchdeclare ([ii, jj], symbolp);

tellsimp (kron_delta (ii, jj), if ii=jj then aa  else bb);
  

[ kron_delta (i1,i1),kron_delta (i1,i2)];

→ don't forget this : otherwise bad result →will follows "below".

kill(kron_deltarule1);

→ sum & kron_delta(,) 
--------------------------------

properties(sum);

1e : step  change properties sum.

declare(sum,linear)$

check :sum "properties"

properties(sum);

2e: step ,range in the sum with matchdeclare : start : ii0,end : ii1

matchdeclare ( [ii0, ii1], all);

3e:step ,tellsimp

tellsimp ('sum (kron_delta (ii, jj), ii, ii0, ii1), 
    if jj=ii then 
    ii1- ii0 + 1
    else 
    if ii0 <= j and j <= ii1 then 
    1 
    else
    0);    

rem :  sum (kron_delta (ii, jj) → [sumrule1,false]
          'sum (kron_delta (ii, jj) → [sumrule1,simpsum]

4e:step ,sum & kron_delta

'sum (E (h (i, j)), i, 1, n);

rem :'sum (E (h (i, j)), i, 1, n) or 'sum (E (h (i, j)), i, 1, n);

foo : subst (E (h (i, j)) = 
    a * kron_delta (i, j) + b * (1 -kron_delta (i, j)), %);
  

reason : kron_delta because , no assuption for: j 
solve : assume , statement

5e: step assume : j , don't forget "and" in assume.

assume(j>=1 and j<=n);

6e: step : final result

method 1: use ,nouns
-------------

foo;

ev(foo,nouns);

method 2: use ''
-------------

'foo;

''foo;

--------------------------------------------------------------------------------------------------------------

double sum , with kron_delta(,)
------------------------------------------

→ 1e) need to forget : j assumption, from above.

forget (j>=1 and j<=n);

→ 2e) sum with kron_delta

'sum ('sum (E (h (i, j)), i, 1, n), j, 1, n);

subst (E (h (i, j)) = a * kron_delta (i, j) + b * (1 - kron_delta (i, j)),%);

→ 3e) final result

ev(%,nouns);

rem : % output from before (%%,%%%,.......)

---------------------------------------------------------------------------------------------------------------------------