Interface

These functions (mostly) form the internal interface of the package, and should not be relevant to most users.

QuantumAlgebra.BaseOperator — Type
BaseOperator

Represents a single quantum operator in an expression.

A BaseOperator is one of:

  • Bosonic operators: BosonCreate, BosonDestroy
  • Fermionic operators: FermionCreate, FermionDestroy
  • Two-level system (TLS) operators: TLSCreate, TLSDestroy, TLSx, TLSy, TLSz

Each operator is associated with a name and indices.

Examples

a = BosonCreate(:a)        # Bosonic creation operator a†
f = FermionDestroy(:f, 1)  # Fermionic annihilation operator f₁
σx = TLSx(:σ, :i)          # TLS x operator σ_i
source
QuantumAlgebra.Corr — Type
Corr(ops::BaseOpProduct)

Represents a correlator ⟨ops⟩c in a quantum expression.

Correlators (or cumulants) represent connected correlations in the expectation value.

Examples

corr = Corr(BaseOpProduct([a, a_dag]))  # ⟨a† a⟩c

See also

ExpVal, corr

source
QuantumAlgebra.ExpVal — Type
ExpVal(ops::BaseOpProduct)

Represents an expectation value ⟨ops⟩ in a quantum expression.

Expectation values contain products of quantum operators that should be evaluated as a single unit.

Examples

ev = ExpVal(BaseOpProduct([a, a_dag]))  # ⟨a† a⟩

See also

Corr, expval

source
QuantumAlgebra.Param — Type
Param(name, state, inds)

Represents a parameter in a quantum expression.

Parameters are scalar values that can appear in quantum expressions, with optional indices and conjugation state.

Arguments

  • name: Symbol identifying the parameter
  • state: 'r' for real, 'n' for normal, 'c' for conjugate
  • inds: Quantum indices (optional)

Examples

p = Param(:λ, 'r')        # Real parameter λ
p = Param(:ω, 'r', 1)     # Real parameter ω₁
source
QuantumAlgebra.QuExpr — Type
QuExpr

A quantum algebra expression represented as a sum of terms.

A QuExpr is a dictionary mapping QuTerms to numeric coefficients stored as Number. Using Number allows heterogeneous numeric types (e.g., Int, Float64, Rational, Complex) to coexist without forced type conversions.

Constructors

  • The quantum operator constructors generated with @boson_ops, @fermion_ops, etc., return QuExpr objects.
  • QuExpr(): Create an empty expression (zero) - zero(QuExpr) works as well.
  • QuExpr(x): Create a constant expression from a number x. QuExpr(1) is equivalent to one(QuExpr).

See also

QuTerm, normal_form

source
QuantumAlgebra.QuExprConstructor — Type
QuExprConstructor

Helper struct for creating operator expressions with automatic conjugate support.

Used internally by macros like @boson_ops and @fermion_ops to provide both normal and daggered operator constructors.

source
QuantumAlgebra.QuIndex — Type
QuIndex

Represents an index in a quantum operator expression.

A QuIndex can be:

  • An integer index (created with QuIndex(i) for integer i)
  • A symbolic index like QuIndex(:i) or QuIndex("i_2")
  • A sum index created with sumindex(n)

Examples

i = QuIndex(1)              # Integer index 1
i = QuIndex(:i)             # Symbolic index 'i'
i = QuIndex("i_2")          # Symbolic index 'i' with subscript 2
si = sumindex(1)            # Sum index #₁

See also

sumindex, issumindex, isintindex

source
QuantumAlgebra.QuTerm — Type
QuTerm

Represents a single term in a quantum algebra expression.

A term consists of:

  • Sum indices (summed-over indices)
  • Delta functions
  • Parameters
  • Expectation values
  • Correlators/cumulants
  • Bare operators

See also

QuExpr, BaseOperator

source
QuantumAlgebra.SOVariable — Type
SOVariable

The generators of so(n) created by so or @so: L(a,b) is the generator $L_{ab}$ (for generators with indices, an object that is indexed with the indices, L(a,b)[k]).

source
QuantumAlgebra.WorkTerm — Type
WorkTerm

Mutable working form of a QuTerm used while normal ordering. All vectors are owned by the WorkTerm and can be modified freely. Convert back with QuTerm(w::WorkTerm).

source
QuantumAlgebra._COWDict — Type
_COWDict{K,V}()

A dictionary that can be read from several threads without locking. It is never modified in place, but replaced as a whole (under a lock) when entries are added, so it is only meant for small tables (such as caches with few entries).

source
QuantumAlgebra.δ — Type
δ(iA, iB)

Represents a Kronecker delta function δ_{iA,iB} in a quantum expression.

The delta function is zero if indices are different, and one if they are the same.

Examples

δ(QuIndex(1), QuIndex(2))    # δ₁₂
δ(QuIndex(:i), QuIndex(:j))  # δᵢⱼ
source
QuantumAlgebra.Avac — Method
Avac(A, modes_in_vacuum=nothing)
vacA(A, modes_in_vacuum=nothing)

Simplify an operator expression by acting on the vacuum from the right (Avac) or from the left (vacA). Returns a new QuExpr with terms that annihilate the vacuum removed and with any TLS σz eigenvalue simplifications applied. Set modes_in_vacuum to an operator or an iterable of operators to restrict the vacuum assumption to these modes; defaults to all modes. The operators are given without indices, i.e., as the variables defined by the macros (e.g., a after @boson a or @boson a[:]), and stand for all modes of an operator with indices.

source
QuantumAlgebra.CorrPerm_isless — Method
CorrPerm_isless(a,b)

isless for Tuples of Tuples representing products of Corr (see above) of a permutation of operators. E.g., ((1,3),(2,)) represents <A1 A3>C <A2>C. It is assumed that the total number of operators in a and b is equal, i.e., that sum(length.(a)) == sum(length.(b)).

source
QuantumAlgebra.CorrTup_isless — Method
CorrTup_isless(a,b)

isless for Tuples of integers that represent Corr of sorted operators (with n representing An such that n<m == An<Am). (n,m,...) ≡ Corr(AnAm...). Defined in such a way that the same order is obtained as with BaseOperator objects

source
QuantumAlgebra._canonicalize_suminds — Method
_canonicalize_suminds(t::QuTerm)

Renumber the sum indices of the normal-ordered term t canonically. Returns (tc, sign, isnormal) such that t = sign*tc, where isnormal is true if tc is in normal form, or nothing if the term vanishes (because renumbering gives the same term with opposite sign).

source
QuantumAlgebra._encode_term — Method
_encode_term(nsuminds, δs, params, expvals, corrs, bares, fδ, f)

Create a QuTerm from its parts. Each part is a tuple of collections whose concatenation gives the respective part of the term. The index function fδ is applied to the indices of the δs and f to all other indices (nothing stands for no change). Index functions are applied in the order in which the indices are stored, i.e., δs, params, expvals, corrs, bares.

source
QuantumAlgebra.auto_normal_form — Function
auto_normal_form(t::Bool=true; set_preference=false)

Enable or disable automatic normal-ordering of expressions on construction. When set_preference is true, the setting is stored with Preferences.jl.

source
QuantumAlgebra.boson — Method
boson(name; ndims=0)

Return the bosonic annihilation operator name (the function version of @boson), where name is a Symbol or a string (which can be any name, e.g., "c↑"). With ndims=0, this is the operator itself, and otherwise an object a such that a[i,j,…] (with ndims indices) is the operator with these indices. The creation operator is obtained as a' (or a'[i,j,…]).

source
QuantumAlgebra.boson_ops — Method
boson_ops(name::Symbol)

Create constructors for bosonic operators with the given name.

Returns a tuple of (annihilation, creation) operators that can be called to create quantum expressions containing these operators.

Arguments

  • name: Symbol for the operator name (e.g., :a, :b)

Returns

  • Tuple (a, a†) of QuExprConstructor objects

Examples

a, a_dag = boson_ops(:a)
expr = a(1) + a_dag(2)  # a₁ + a₂†

See also

fermion_ops, @boson_ops

source
QuantumAlgebra.comm — Method
comm(A, B)

Compute the commutator $[A,B] = A*B - B*A$, in normal form.

The commutator is computed directly from the commutators of pairs of single operators (with the Leibniz rule), so that only the terms that do not cancel are generated.

source
QuantumAlgebra.contract! — Method

contract!(emit, A, B): simplify the product A B. Returns nothing if it does not simplify, or (fac, op) with A B = fac op + R (see exchange! for R).

source
QuantumAlgebra.corr — Method
corr(A)

Wrap bare operators inside A into a formal connected correlator ⟨A⟩₍c₎. Accepts QuTerm or QuExpr; numeric inputs are returned as constant expressions.

source
QuantumAlgebra.dropcorr — Method
dropcorr(n::Int)

Returns a filter function that rewrites terms with correlations corrs or expectation values expvals of length greater than n in terms of lower-order expressions (up to order n) and higher-order correlators, and then drops those higher-order correlations.

For example, dropcorr(1) will replace $⟨a^† a⟩ = ⟨a^† a⟩_c + ⟨a^†⟩ ⟨a⟩ ≈ ⟨a^†⟩ ⟨a⟩$.

source
QuantumAlgebra.droplen — Method
droplen(n)

Create a filter that drops correlators/expectation values with length greater than n. Useful for truncating hierarchies of equations.

source
QuantumAlgebra.exchange! — Method

exchange!(emit, B, A): rewrite B A = x A B + R, with A < B. Passes the terms of R to emit(c, δs, ops...) and returns x.

source
QuantumAlgebra.expval — Method
expval(A)

Wrap bare operators inside A into a formal expectation value ⟨A⟩. Accepts QuTerm or QuExpr; numeric inputs are returned as constant expressions.

source
QuantumAlgebra.expval2corrs_inds — Method
expval2corrs_inds(N::Int)

for N operators, create an array of partitions (see OpPartition) that represents the terms in a sum of products of correlators. Each partition corresponds to a sum term. Internally, they are computed as tuples of tuples, see CorrTup_isless and CorrPerm_isless for details. The returned array and terms are sorted such that if the N operators are sorted, the represented expression is also sorted with the conventions of the QuantumAlgebra package. This allows to directly return a normal-ordered form.

source
QuantumAlgebra.expval_as_corrs — Method
expval_as_corrs(expr::QuExpr)

Take an expression expr=A B C + D E... and write its expectation value in terms of correlations $⟨A⟩_c, ⟨B⟩_c, ⟨AB⟩_c, ⟨ABC⟩_c, \ldots$. Note that $⟨A⟩_c = ⟨A⟩$.

E.g., expval_as_corrs(a'(:n)*a(:n)) returns $⟨a^\dagger_n a_n⟩_c + ⟨a^\dagger_n⟩_c ⟨a_n⟩_c$ (which is equal to $⟨a^\dagger_n a_n⟩$), while expval_as_corrs(a'(:n)*a(:m)*a(:n)) returns $\langle a_{n}^\dagger a_{m} a_{n} \rangle_{c} + \langle a_{n}^\dagger \rangle_{c} \langle a_{m} \rangle_{c} \langle a_{n} \rangle_{c} + \langle a_{n}^\dagger \rangle_{c} \langle a_{m} a_{n} \rangle_{c} + \langle a_{m} \rangle_{c} \langle a_{n}^\dagger a_{n} \rangle_{c} + \langle a_{n} \rangle_{c} \langle a_{n}^\dagger a_{m} \rangle_{c}$.

See also: expval, corr

source
QuantumAlgebra.fermion_ops — Method
fermion_ops(name::Symbol)

Create constructors for fermionic operators with the given name.

Returns a tuple of (annihilation, creation) operators that can be called to create quantum expressions containing these operators.

Arguments

  • name: Symbol for the operator name (e.g., :f, :c)

Returns

  • Tuple (f, f†) of QuExprConstructor objects

Examples

f, f_dag = fermion_ops(:f)
expr = f(1) + f_dag(2)  # f₁ + f₂†

See also

boson_ops, @fermion_ops

source
QuantumAlgebra.gellmann — Method
gellmann(q::QuditVariable; sqrt=Base.sqrt)

Return the d²-1 generalized Gell-Mann matrices $λ_1, …, λ_{d²-1}$ of the d-level qudit q (see qudit), with the standard normalization $\mathrm{Tr}(λ_a λ_b) = 2δ_{ab}$ (for a qudit with indices, as objects that are indexed with the indices, λ[1][k]). For k = 2, …, d, these are (in this order) the pairs $|j⟩⟨k| + |k⟩⟨j|$ and $-i|j⟩⟨k| + i|k⟩⟨j|$ for $j = 1, …, k-1$, followed by the diagonal matrix $\sqrt{2/(l(l+1))} (\sum_{m≤l} |m⟩⟨m| - l |l+1⟩⟨l+1|)$ with $l = k-1$. For d = 3, these are the Gell-Mann matrices $λ_1, …, λ_8$ in their usual order. Note that since level 1 is the ground state, for d = 2 they correspond to $(σ^x, -σ^y, -σ^z)$.

The normalization factors $\sqrt{2/(l(l+1))}$ of the diagonal matrices are computed by calling sqrt with the rational number 2//(l*(l+1)) (unless the result is rational, e.g., for l = 1). By default, this gives Float64 numbers. To keep them exact, pass a function that computes the square root symbolically, e.g., sqrt = x -> sqrt(SymPyPythonCall.Sym(x)).

Examples

q = qudit(:q, 3)
λ = gellmann(q)
normal_form(comm(λ[1], λ[2]))  # 2i λ₃
λ[8]                           # 0.57735 - 1.73205 q³³()
source
QuantumAlgebra.heisenberg_eom — Function
heisenberg_eom(A, H; Ls=())

Compute the Heisenberg equation of motion for an observable A with Hamiltonian H and optional Lindblad operators Ls.

Returns $\dot{A} = i [H,A] + \sum_i (L_i^† A L_i - \tfrac{1}{2} \{L_i^† L_i, A\})$.

source
QuantumAlgebra.heisenberg_eom_system — Function
heisenberg_eom_system(H, rhsfilt, Ls=(), ops=nothing)

Calculates the system of Heisenberg equations of motion for either the expectation values or the cumulants / correlators of operator products, starting from a Hamiltonian H and a list of Lindblad terms Ls describing decoherence.

rhsfilt is a filter function that is applied to the right-hand side of the equations. Typically, these equation systems are not closed without approximations as equations for products of n operators involve products of m>n operators, so the system has to be truncated. This is achieved with the filter function that removes higher-order terms or rewrites them (approximately) in terms of lower-order expressions.

ops is an optional list of operators for which the equations should be generated. If ops is nothing (default), the function will try to determine the relevant operators automatically from the Hamiltonian and Lindblad terms.

The function returns a QuEqSys object containing the system of equations.

Examples

julia> using QuantumAlgebra
julia> @boson_ops a;
julia> H = Pr"ω"*a'()*a() + Pr"χ"*a'()*(a'()+a())*a();
julia> Ls = ((Pr"γ",a()),);
julia> EQ = heisenberg_eom_system(H,2,Ls,a())
dₜ⟨a()⟩ = -1//2 γ ⟨a()⟩  - 1i ω ⟨a()⟩  - 2i χ ⟨a†() a()⟩  - 1i χ ⟨a()²⟩ 
dₜ⟨a†() a()⟩ = -γ ⟨a†() a()⟩ 
dₜ⟨a()²⟩ = -2i χ ⟨a()⟩  - γ ⟨a()²⟩  - 2i ω ⟨a()²⟩ 
source
QuantumAlgebra.julia_expression — Function
julia_expression(A; varnames=nothing)

Convert a QuExpr (or related quantum objects) into a plain Julia expression constructed from numbers and symbolic variables. Optional varnames argument restricts allowed expectation value or correlator symbols; when provided, conjugates may be rewritten to match available names.

source
QuantumAlgebra.latex — Method
latex(A)

Render any QuantumObject to a raw LaTeX string using Latexify.jl recipes. Useful for pretty-printing expressions or embedding results in documents.

source
QuantumAlgebra.map_scalar_function — Method
map_scalar_function(f, A::QuExpr)

Apply a function to all scalar coefficients in a quantum expression.

Arguments

  • f: Function to apply to each coefficient
  • A: Quantum expression

Returns

A new QuExpr with function applied to all coefficients

Examples

A = QuExpr(a) + 2 * QuExpr(a_dag)
B = map_scalar_function(x -> 2x, A)  # Double all coefficients
source
QuantumAlgebra.normal_form — Function
normal_form(A::QuExpr; shortcut_vacA_zero=false)

Return an equivalent expression in normal-ordered form (all commutations performed).

shortcut_vacA_zero can be set to true when the expression will be multiplied by a vacuum state from the right, allowing early elimination of annihilation terms.

source
QuantumAlgebra.normal_order! — Function
normal_order!(ops::BaseOpProduct, term_collector, shortcut_vacA_zero=false, prefactor=1)

Bring the operator product ops into normal order in place. Returns the prefactor p of the reordered product, such that the original prefactor*ops is equal to p*ops (after reordering) plus the terms that are added to term_collector (which still have to be normal ordered).

source
QuantumAlgebra.ops — Method

ops(A::Union{ExpVal,Corr}): the product of operators inside the expectation value or correlator

source
QuantumAlgebra.param — Method
param(name, [state], inds...)

Construct a parameter as a QuExpr. state is one of n (normal/complex), r (real), or c (conjugate). Indices are optional.

source
QuantumAlgebra.qindex — Method
qindex(name::Symbol; ndims=0)

Return the index name (the function version of @qindex): with ndims=0, the index itself, and with ndims=1, an object j such that j[n] is the index with name j and numeric subindex n (printed as jₙ).

source
QuantumAlgebra.qparam — Function
qparam(name, T=Real; ndims=0)

Return the parameter name (the function version of @qparam), which is real for T = Real and complex for T = Complex. The name is a Symbol or a string, which can be any name, e.g., "f(t)" (which is also how the parameter appears in julia_expression). With ndims=0, this is the parameter itself, and otherwise an object g such that g[i,j,…] (with ndims indices) is the parameter with these indices. For a complex parameter α, α' (or α'[i]) is its complex conjugate.

source
QuantumAlgebra.qudit — Method
qudit(name, d::Integer; ndims=0)

Return the qudit (d-level system) name (the function version of @qudit), such that q(i,j) is the transition operator $|i⟩⟨j|$ (with levels 1 ≤ i,j ≤ d). With ndims > 0, the qudit has ndims indices, given as q(i,j)[k,…]. Level 1 is the ground state, i.e., the vacuum.

Internally, all operators are expressed through the "creation" operators $|i⟩⟨1|$ and "annihilation" operators $|1⟩⟨i|$ (with $i ≥ 2$), using $|i⟩⟨j| = |i⟩⟨1|1⟩⟨j|$ and $|1⟩⟨1| = 1 - \sum_{k≥2} |k⟩⟨1|1⟩⟨k|$, which gives a unique normal form. For d=2, q(2,1) and q(1,2) are equivalent to $σ^{+}$ and $σ^{-}$. When printing, products $|i⟩⟨1|1⟩⟨j|$ acting on the same qudit are shown as $|i⟩⟨j|$ (written qⁱʲ).

Examples

q = qudit(:q, 3)
normal_form(q(1,2)*q(2,3)) # |1⟩⟨3|
q(1,1)                     # 1 - |2⟩⟨2| - |3⟩⟨3|
r = qudit(:r, 3; ndims=1)
r(2,3)[:i]                 # |2⟩⟨3| = |2⟩⟨1|1⟩⟨3| acting on qudit i
source
QuantumAlgebra.qudit_op — Method

qudit_op(name, d, i, j, inds): the operator |i⟩⟨j| of a d-level system, with either i == 1 or j == 1 (but not both)

source
QuantumAlgebra.set_define_default_ops — Method
set_define_default_ops(t::Bool)

Set the preference for whether to define default operators (a, adag, f, fdag, σx, σy, σz, σp, σm) upon import. Default is true.

Note that changing this preference requires restarting the Julia session to take effect.

source
QuantumAlgebra.set_quindices_type — Method
set_quindices_type(t::String)

Deprecated: indices are now always stored in a compact form that supports an arbitrary number of indices, so the "quindices_type" preference no longer has any effect.

source
QuantumAlgebra.so — Method
so(name, n::Integer; ndims=0)

Return the generators L of the Lie algebra so(n) of rotations in n dimensions (the function version of @so), such that L(a,b) is the generator $L_{ab} = -L_{ba}$ ($a,b = 1,…,n$). With ndims > 0, the generators have ndims indices, given as L(a,b)[k,…]. The generators are Hermitian, with

\[[L_{ab}, L_{cd}] = i (δ_{ac} L_{bd} - δ_{ad} L_{bc} - δ_{bc} L_{ad} + δ_{bd} L_{ac}),\]

as, e.g., for the angular momenta $L_{ab} = x_a p_b - x_b p_a$ of a particle in n dimensions (for n = 3, $(L_x, L_y, L_z) = (L_{23}, L_{31}, L_{12})$). Only these commutation relations are used, so that results hold in any representation. Operators are stored and printed as $L_{ab}$ with $a < b$.

Examples

L = so(:L, 4)
L(2,1)                             # -L¹²()
normal_form(comm(L(1,2), L(2,3)))  # -i L¹³()
source
QuantumAlgebra.spin — Function
spin(name, j=nothing; ndims=0)

Return the operators (Jp, Jm, Jz), i.e., $J_+$, $J_-$ and $J_z$, of the spin name (the function version of @spin), see boson for ndims. They generate the Lie algebra su(2) ≅ so(3), with $[J_z,J_±] = ±J_±$ and $[J_+,J_-] = 2J_z$. If j is not given, only these commutation relations are used, which hold in any representation (e.g., for collective spins). If the spin j is given (any number, e.g., 1//2, 3, or a symbolic variable), products $J_+ J_-$ acting on the same spin are replaced by $j(j+1) - J_z^2 + J_z$, and the vacuum is the lowest-weight state with $J_-|0⟩ = 0$ and $J_z|0⟩ = -j|0⟩$. Note that other relations that hold for a specific j (e.g., $J_+^2 = 0$ for j = 1//2) are not used.

source
QuantumAlgebra.sumindex — Method
sumindex(i)

Create a summation index with index i. These indices are used internally for implicit summation (Einstein summation convention).

source
QuantumAlgebra.tls — Method
tls(name; ndims=0)

Return the lowering operator $σ^-$ of the two-level system name (the function version of @tls), see boson. The raising operator $σ^+$ is obtained as σ'. The operators are represented as jump operators or through Pauli matrices depending on use_σpm (at the time the operator is created).

source
QuantumAlgebra.tlspm_ops — Method
tlspm_ops(name::Symbol)

Return constructors for TLS ladder operators (σ₋, σ₊) for the given name.

The concrete output depends on use_σpm: when true, returns annihilation/creation expressions; when false, returns linear combinations of σx and σy.

source
QuantumAlgebra.tlsxyz_ops — Method
tlsxyz_ops(name::Symbol)

Return constructors for Pauli operators (σₓ, σ_y, σ_z) for the given name.

The concrete output depends on use_σpm: when true, returns combinations of ladder operators; when false, returns the direct σx/σy/σz operators.

source
QuantumAlgebra.use_bracket_display — Function
use_bracket_display(t::Bool=true; set_preference=false)

Select whether operators and parameters are printed in the syntax of the interface with operator variables (see @boson), e.g., a†[i,j], g[i] and a (for true), or with parentheses, e.g., a†(ij), g(i) and a() (for false, the default in v1.x). If set_preference is true, the choice is stored with Preferences.jl for future sessions.

source
QuantumAlgebra.use_σpm — Function
use_σpm(t::Bool=true; set_preference=false)

Select whether TLS operators are expressed in the (σ₊, σ₋) basis (true) or in the (σx, σy, σz) basis (false). If set_preference is true, the choice is persisted via Preferences.jl for future sessions.

source
QuantumAlgebra.use_σxyz — Method
use_σxyz(; set_preference=false)

Convenience helper to switch to the (σx, σy, σz) basis. Equivalent to use_σpm(false; set_preference).

source
QuantumAlgebra.vacExpVal — Function
vacExpVal(A::QuExpr, S::QuExpr=1, modes_in_vacuum=nothing)

Calculate the vacuum expectation value $⟨0|S^\\dagger A S|0⟩$, i.e. the expectation value $⟨ψ|A|ψ⟩$ for the state $|ψ⟩ = S|0⟩$. Optionally restrict the vacuum assumption to specific modes via modes_in_vacuum (see Avac).

source
QuantumAlgebra.ϵ_ab — Method

ϵ_ab(A,B): for Pauli matrices σᵃ, σᵇ (with a≠b), return the third one, σᶜ, and the Levi-Civita symbol ϵ_abc

source
QuantumAlgebra.@boson — Macro
@boson a
@boson a[:,:]
@boson a b[:] ...
@boson au="a↑" ad[:]="a↓" ...

Define the variable a for a bosonic annihilation operator (see boson). With a[:,:] (with any number of :), the operator has as many indices, given as a[i,j] (with indices declared by @qindex, or with symbols and integers, e.g., a[:i,2]). The creation operator is a' (or a'[i,j]). Several operators can be defined at once, and with au = "a↑", the variable au is an operator with the name a↑ (also for the other macros that define operators or parameters). This can be any name, e.g., one that is not a valid variable name. Note that unicode characters in names are converted to LaTeX for LaTeX output (e.g., @boson b̄ gives $\bar{b}$), so a LaTeX name (which is also used for text output) is usually not needed.

source
QuantumAlgebra.@boson_ops — Macro

@boson_ops name: define function $name for creating bosonic annihilation operators with name name (also defines deprecated $(name)dag, use $(name)' instead)

source
QuantumAlgebra.@fermion_ops — Macro

@fermion_ops name: define function $name for creating fermionic annihilation operators with name name (also defines deprecated $(name)dag, use $(name)' instead)

source
QuantumAlgebra.@qindex — Macro
@qindex i j[:] ...

Define the indices i, j, … (see qindex), where an index declared as j[:] has a numeric subindex, j[2] (printed as j₂). Indices can then be used directly, e.g., a[i,j[2]] (instead of a[:i,:j_2]).

source
QuantumAlgebra.@qparam — Macro
@qparam g
@qparam g[:,:] α::Complex ft="f(t)" ...

Define the variable g for a real parameter, or several parameters at once (see qparam). With g[:,:] (with any number of :), the parameter has indices, given as g[i,j]. Parameters declared as α::Complex (or α[:]::Complex) are complex, and α' (or α'[i]) is their complex conjugate. With ft = "f(t)", the variable ft is the parameter with the name f(t) (see @boson).

source
QuantumAlgebra.@qudit — Macro
@qudit d q
@qudit d q[:,:]
@qudit d q r[:] ...

Define the variable q for a qudit with d levels (see qudit), such that q(i,j) is the transition operator $|i⟩⟨j|$. With q[:,:] (with any number of :), the qudit has indices, which are given as q(i,j)[k,l]. With several names, all qudits have d levels.

Examples

@qudit 3 q
q(2,1) * q(1,3)        # |2⟩⟨3|
@qudit 3 m[:]
∑(:k, m(2,1)[:k] * m(1,2)[:k])
source
QuantumAlgebra.@so — Macro
@so n L
@so n L[:,:]
@so n L M[:] ...

Define the variable L for the generators of so(n) (see so), such that L(a,b) is the generator $L_{ab}$. With L[:,:] (with any number of :), the generators have indices, which are given as L(a,b)[k,l]. With several names, all of them are generators of so(n) for the same n.

source
QuantumAlgebra.@spin — Macro
@spin J
@spin J K[:] ...
@spin 1//2 J K[:] ...
@spin j=jval J K[:] ...

Define the variables Jp, Jm and Jz for the operators $J_+$, $J_-$ and $J_z$ of a spin J (see spin), and similarly for each further name. With J[:,:] (with any number of :), the spin has indices, given as, e.g., Jp[i,j]. A fixed spin j (the same for all names) is given as the first argument if it is a number (e.g., 1//2 or 3), and as j=jval otherwise (e.g., for a variable jval or a symbolic value), since a name as the first argument is interpreted as the name of a spin. (j = "name", with a string, is the spin j with that name.)

source
QuantumAlgebra.@tls — Macro
@tls σ
@tls σ[:] τ ...

Define the variable σ for the lowering operator $σ^-$ of a two-level system, with $σ^+$ = σ' (see tls and @boson).

source
QuantumAlgebra.@tlspm_ops — Macro

@tlspm_ops name: define functions $(name)m and $(name)p creating jump operators for a two-level system with name name.

source
QuantumAlgebra.@tlsxyz — Macro
@tlsxyz σ
@tlsxyz σ[:] τ ...

Define the variables σx, σy and σz for the Pauli matrices of a two-level system (see tlsxyz and @boson), and similarly for each further name.

source
QuantumAlgebra.@tlsxyz_ops — Macro

@tlsxyz_ops name: define functions $(name)x, $(name)y, and $(name)z creating Pauli operators for a two-level system with name name.

source