Skip to content

Instantly share code, notes, and snippets.

View hugle's full-sized avatar
🎯
Focusing

Hugle hugle

🎯
Focusing
View GitHub Profile
@hugle
hugle / sumexpand.nb
Last active April 17, 2022 19:16
Expand summation expression and apply the distribution law
SumExpand[exp_] :=
exp /. Sum[c_, {i_, a_, b_}] :>
Distribute[Sum[ExpandAll[c], {i, a, b}]];
rule = Sum[Times[Longest[u___], x___], {y_, z___}] :>
Times[u] Sum[Times[x], {y, z}] /; (FreeQ[{u}, y]);
SumSimplify[exp_] := SumExpand[exp] /. rule