q-arithmetic and helpers¶
utils ¶
utils.py¶
q-arithmetic helpers: q-integers, q-factorials and q-binomial coefficients.
Definitions
q-integer: [n]_q = (q^n - q^{-n}) / (q - q^{-1}) = q^{n-1} + q^{n-3} + ... + q^{-(n-1)}
q-factorial: [n]_q! = [n]_q [n-1]_q ... [1]_q, [0]_q! = 1
q-binomial: [n choose k]_q = [n]_q! / ([k]_q! [n-k]_q!)
These functions return SymPy expressions, so q can remain symbolic or be assigned a numerical value with subs() when needed.
q_integer ¶
q_integer(n: int, q_sym: Expr = q) -> sp.Expr
Return the q-integer [n]_q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
May be nonnegative or negative; [-n]_q = -[n]_q. |
required |
q_sym
|
sympy expression
|
The q parameter. Defaults to the module symbol |
q
|
Returns:
| Type | Description |
|---|---|
sympy expression.
|
|
Example
q_integer(3) q2 + 1 + q(-2)
Source code in quantum_group/utils.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
q_factorial ¶
q_factorial(n: int, q_sym: Expr = q) -> sp.Expr
Return the q-factorial [n]_q! = [n]_q [n-1]_q ... [1]_q.
Source code in quantum_group/utils.py
62 63 64 65 66 67 68 69 70 | |
q_binomial ¶
q_binomial(n: int, k: int, q_sym: Expr = q) -> sp.Expr
Return the q-binomial coefficient [n choose k]_q (zero unless 0 <= k <= n).
Source code in quantum_group/utils.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
classical_limit ¶
classical_limit(expr: Expr, q_sym: Expr = q) -> sp.Expr
Compute the classical limit q -> 1 (using L'Hôpital's rule).
This is useful for symbolic checks of limits such as [n]_q -> n.
Source code in quantum_group/utils.py
93 94 95 96 97 98 | |
linalg ¶
linalg.py¶
Small exact-matrix helpers shared by the verification modules.
kron/kron_list— Kronecker (tensor) products of SymPy matrices, using the standard basis order in which the left factor's index changes slowly and the right factor's index changes quickly.is_zero_matrix— the zero-residual test used throughout the package.
These helpers were previously duplicated as private functions in several
modules (hopf._kron, r_matrix._is_zero,
supergroup_gl21._is_zero_matrix_symbolic). Those names remain as
aliases for backward compatibility.
kron ¶
kron(A: Matrix, B: Matrix) -> sp.Matrix
Return the Kronecker product A ⊗ B of two SymPy matrices.
kron(sp.eye(2), sp.Matrix([[0, 1], [1, 0]])).shape (4, 4)
Source code in quantum_group/linalg.py
25 26 27 28 29 30 31 32 33 34 35 36 37 | |
kron_list ¶
kron_list(mats: Sequence[Matrix]) -> sp.Matrix
Return the left-to-right Kronecker product of the given matrices.
Source code in quantum_group/linalg.py
40 41 42 43 44 45 46 47 | |
is_zero_matrix ¶
is_zero_matrix(M: Matrix) -> bool
Return whether every entry of M simplifies to zero.
True means each entry was reduced to the exact value 0 by
sympy.simplify. False means at least one entry was not; for
arbitrary SymPy expressions this is not by itself a proof that the
entry is nonzero, because simplify is not a decision procedure.
For the rational functions of q produced by this package, a
nonzero result can be confirmed with sympy.cancel.
Source code in quantum_group/linalg.py
50 51 52 53 54 55 56 57 58 59 60 | |