qnet.algebra.toolbox module

Collection of tools to manually manipulate algebraic expressions

Summary

Functions:

evaluate_commutators Evaluate all commutators in expr.
expand_commutators_leibniz Recursively expand commutators in expr according to the Leibniz rule.

__all__: evaluate_commutators, expand_commutators_leibniz

Reference

qnet.algebra.toolbox.expand_commutators_leibniz(expr, expand_expr=True)[source]

Recursively expand commutators in expr according to the Leibniz rule.

\[[A B, C] = A [B, C] + [A, C] B\]
\[[A, B C] = [A, B] C + B [A, C]\]

If expand_expr is True, expand products of sums in expr, as well as in the result.

qnet.algebra.toolbox.evaluate_commutators(expr)[source]

Evaluate all commutators in expr.

All commutators are evaluated as the explicit formula

\[[A, B] = A B - B A\]