sum

◼ sum[expr,{indexes}] denotes a symbolic sum of an expression over indexes.

◼ The indexes that will be used may be declared using snegfreeindexes.

◼ See also: snegfreeindexes.

Further examples

Load sneg and declare some quantities.

<< sneg`sneg`;
snegfermionoperators[c]
ordering[c] = SEA;
snegfreeindexes[k, k1, 
      k2, σ, σ1, σ2]
snegrealconstants[x]

Summation over no indexes is equivalent to the expression itself

sum[expr, {}]

The order of indexes is irrelevant

sum[expr, {k, σ}] == sum[expr, {σ, k}]

Constants are factored out of the sum, but numeric expressions which depend on the indexes are not.

sum[2 expr, {k, σ}]
sum[x expr, {k, σ}]
sum[UnitStep[x] expr, {k, σ}]

    
sum[k expr, {k, σ}]
sum[UnitStep[k] expr, {k, σ}]

Sums can be conjugated

sum[c[CR, k, σ], {k, σ}]
conj[%]

Multiple sums in a single nc expression and repeated sums are merged into a single sum over all of the indexes.

nc[sum[expr1, {k1, σ1}], 
      sum[expr2, {k2, σ2}]]
sum[sum[expr, {k1, σ1}], {k2, σ2}]

If two sums with conflicting index names are multiplied, and sumAutoRename=True (this is the default), the indexes will be automatically renamed.

nc[sum[expr1, {k}], sum[expr2, {k}]]

If there is an index name conflit and sumAutoRename=False, a warning message will be emitted and no renaming is performed.

sumAutoRename = False;
nc[sum[expr1, {k}], sum[expr2, {k}]]
sum[sum[expr, {k}], {k}]

Kinetic energy Hamiltonian

SetAttributes[eps, NumericFunction]
Conjugate[eps[k_]] ^= eps[k];
H = sum[eps[k] number[c[k], σ], {k, σ}]

Simple commutators

komutator[H, c[CR, k1, σ1]]
sumSimplify[%]
komutator[H, c[AN, k1, σ1]]
sumSimplify[%]