Noncommutative algebra API¶
Expressions over noncommutative symbols (pool.symbol(name,
commutative=False)) read as noncommutative polynomials, with word-rewriting
normal forms. See the Noncommutative algebra chapter of the user guide.
- alkahest.nc_expand(expr) Expr¶
Distribute products keeping factor order, unroll non-negative integer powers of noncommutative factors, collect equal words.
- alkahest.nc_terms(expr) list[tuple[Expr, list[Expr]]]¶
The
(coefficient, word)terms ofnc_expand().
- alkahest.nc_rewrite(expr, rules, *, max_steps=200000) Expr¶
Rewrite to a normal form with literal word rules from
make_rule(), matching inside longer words. RaisesNcErrorE-NC-001when no normal form is reached withinmax_steps,E-NC-003for a left side that is not a single word.
- alkahest.anticommutator(a, b, rules=None) Expr¶
a*b ∓ b*aexpanded; withrules, rewritten bync_rewrite().
- alkahest.normal_order(expr, bosons=None, fermions=None) Expr¶
Normal-order with
[a, a†] = 1(bosons) and{c, c†} = 1,c² = 0(fermions).bosons/fermionsare(annihilator, creator)pairs or lists of them. RaisesE-NC-004for a malformed mode list.
- alkahest.vacuum_expectation(expr, bosons=None, fermions=None) Expr¶
⟨0|expr|0⟩, the scalar part ofnormal_order(). RaisesE-NC-007for a factor that is not a listed ladder operator.
- alkahest.gamma_trace(slots, pool=None) Expr¶
Four-dimensional Dirac trace, metric
diag(+1,−1,−1,−1),γ⁵ = iγ⁰γ¹γ²γ³. Slots are0–3,5or a commutativeExpr(slashed vector). The result is a polynomial indot(p, q)andlevi_civita(a, b, c, d)(ε^{0123} = +1). RaisesE-NC-005for a bad slot andE-NC-006past 14 slots.
simplify_pauli reduces any word over sx, sy, sz with the full
Pauli algebra; make_rule / simplify_with match product patterns inside
longer products (contiguous runs for noncommutative products, sub-multisets for
commutative ones).
Refusals raise NcError (E-NC-001 … E-NC-007); see Error handling API.