Operator functions

Some Hamiltonians are not polynomials in the ladder operators. A trapped ion driven by a laser picks up the phase of the light at its position, and its motion enters through the displacement $e^{i\eta(a + a^\dagger)}$ with the Lamb–Dicke parameter $\eta$,

\[H = \nu a^\dagger a + \frac{\Omega}{2} \left( \sigma^{21} e^{i\eta(a + a^\dagger)} + \sigma^{12} e^{-i\eta(a + a^\dagger)} \right).\]

Functions of operators such as this exponential, or the cosine potential of a Josephson junction, are kept as formal functions. They take part in the algebra without being expanded, and a Taylor expansion to a chosen order turns them into polynomials when needed.

Formal functions

The exponential $e^{iA}$ of a Hermitian operator is written expim, which also writes unit phases of numbers. With it the trapped-ion Hamiltonian reads as on paper.

using SecondQuantizedAlgebrah = FockSpace(:motion) ⊗ NLevelSpace(:ion, 2)@qnumbers a::Destroy(h, 1)σ(k, l) = Transition(h, :σ, k, l)@variables η Ω νH = ν * a' * a + Ω / 2 * (σ(2, 1) * expim(η * (a + a')) + σ(1, 2) * expim(-η * (a + a')))

\[\nu a^{\dagger}a + \frac{1}{2} ~ \Omega {\sigma}^{{12}} e^{i\left( - \eta a - \eta a^{\dagger} \right)} + \frac{1}{2} ~ \Omega {\sigma}^{{21}} e^{i\left( \eta a + \eta a^{\dagger} \right)}\]

Sine and cosine of operators are formal in the same way. There is no exp of an operator; $e^{iA}$ is written expim(A).

SecondQuantizedAlgebra.expim — Method
expim(A)

Exponential of im times a Hermitian operator expression, kept as a formal function.

The result is the unitary $e^{iA}$. A must be Hermitian as written, meaning that A - A' simplifies to zero; parameters in it must therefore be real. Otherwise an ArgumentError is thrown. No series is expanded until taylor is called, and products such as $e^{iA} e^{-iA}$ are not combined. To change the frame of an expression by such a unitary, use a UnitaryTransform, which applies $e^{iA} X e^{-iA}$ exactly.

Examples

julia> a = Destroy(FockSpace(:cavity), :a);julia> @variables θ;julia> U = expim(θ * a' * a)exp(im*(θ * a' * a))julia> taylor(U, 0:1)1 + θim * a' * ajulia> expim(a)ERROR: ArgumentError: `expim(::QField)` requires a provably Hermitian argument[...]

See also taylor, UnitaryTransform, expim(::Real).

source
Base.sin — Method
sin(A)

Sine of an operator expression, kept as a formal function.

No series is expanded. The function enters sums and products like any other operator, and keeps its position relative to operators on the same subsystem. A may be any operator expression. Use taylor to turn the function into a polynomial.

Examples

julia> a = Destroy(FockSpace(:cavity), :a);julia> sin(a + a') * asin(a + a') * ajulia> taylor(sin(a + a'), 0:3)1//2 * a + 1//2 * a' - 1//6 * a * a * a - 1//2 * a' * a * a - 1//2 * a' * a' * a - 1//6 * a' * a' * a'

See also cos, expim, taylor.

source
Base.cos — Method
cos(A)

Cosine of an operator expression, kept as a formal function.

No series is expanded. The function enters sums and products like any other operator, and keeps its position relative to operators on the same subsystem; a commutator with it stays formal. A may be any operator expression. Use taylor to turn the function into a polynomial.

Examples

julia> a = Destroy(FockSpace(:cavity), :a);julia> commutator(cos(a + a'), a)-a * cos(a + a') + cos(a + a') * ajulia> taylor(cos(a + a'), 0:2)1//2 - 1//2 * a * a - a' * a - 1//2 * a' * a'

See also sin, expim, taylor.

source

A formal function keeps its place in a product. It commutes with operators on other subsystems but not with operators it shares a subsystem with.

a * cos(a + a') == cos(a + a') * a, σ(2, 1) * cos(a + a') == cos(a + a') * σ(2, 1)
(false, true)

No identities between functions are applied, not even $\sin^2 + \cos^2 = 1$ or $e^{iA} e^{-iA} = 1$. Where such an identity is needed, it is applied by hand.

expim(η * (a + a')) * expim(η * (a + a'))'

\[e^{i\left( \eta a + \eta a^{\dagger} \right)} e^{i\left( - \eta a - \eta a^{\dagger} \right)}\]

An expression that contains a formal function has its own type, which holds it as written rather than in canonical form.

SecondQuantizedAlgebra.QExpr — Type
QExpr <: QField

Type of operator expressions that contain formal functions such as sin, cos or expim.

Polynomials in the operators are kept in canonical form, with products reordered and like terms collected. An expression containing a formal function cannot be brought into that form, so it is held as written: products keep the order of factors on a shared subsystem, factors on different subsystems are sorted, and products are not multiplied out over sums. Exact operations such as adjoint, substitute or simplify act on the arguments of the functions. taylor turns a QExpr back into an ordinary polynomial. The type is public but not exported.

Examples

julia> using SecondQuantizedAlgebra: QExprjulia> a = Destroy(FockSpace(:cavity), :a);julia> x = (a + a') * cos(a' * a);julia> x isa QExpr, taylor(x, 0:0) isa QExpr(true, false)julia> x'cos(a' * a) * (a + a')

See also sin, cos, expim, taylor.

source

Exact operations

Operations that are exact without an expansion pass through the functions to their arguments. These are the adjoint, substitute, change_index, normal_order, simplify, expand, expand_completeness, assume_distinct_index and the conjugate of a unitary transformation. The Hamiltonian above is Hermitian as a whole.

H' == H
true

Substitution reaches inside the functions, so the Lamb–Dicke parameter can be set to zero to recover the bare two-level drive.

substitute(H, Dict(η => 0))

\[\left( \frac{1}{2} ~ \Omega {\sigma}^{{12}} + \frac{1}{2} ~ \Omega {\sigma}^{{21}} + \nu a^{\dagger}a \right)\]

A unitary transformation acts on the argument of the function, so the result is exact and needs no Baker–Campbell–Hausdorff series.

@variables θR = Rotation(a, θ)conjugate(cos(a + a'), R) == cos(conjugate(a + a', R))
true

A commutator with a formal function stays formal, since evaluating it would need the series.

Taylor expansion

For small $\eta$ the exponentials are expanded. To first order the drive acquires the sidebands $a \sigma^{21}$ and $a^\dagger \sigma^{21}$, which couple the internal state to the motion.

taylor(H, 0:1)

\[\frac{1}{2} ~ \Omega {\sigma}^{{12}} + \frac{1}{2} ~ \Omega {\sigma}^{{21}} - \frac{1}{2} ~ \Omega ~ \eta ~ \mathit{i} a{\sigma}^{{12}} + \frac{1}{2} ~ \Omega ~ \eta ~ \mathit{i} a{\sigma}^{{21}} + \nu a^{\dagger}a - \frac{1}{2} ~ \Omega ~ \eta ~ \mathit{i} a^{\dagger}{\sigma}^{{12}} + \frac{1}{2} ~ \Omega ~ \eta ~ \mathit{i} a^{\dagger}{\sigma}^{{21}}\]

Symbolics.taylor — Function
taylor(expr, 0:n)

Replace every formal operator function in expr by its Taylor polynomial up to order n.

The coefficients are exact and the result is a polynomial in canonical form; an expression without formal functions is returned unchanged. Each function is truncated on its own, so the order is not a total degree of the result: sin(A)^2 truncated at order 1 is A^2, and sin(A)^2 + cos(A)^2 truncated at any order is not 1. A function inside another function throws an ArgumentError; lower the inner part first. So does a function of an argument containing a Σ, since a power such as $(\sum_i A_i)^2$ would need fresh summation indices. The range must start at 0.

Examples

julia> a = Destroy(FockSpace(:cavity), :a);julia> A = a + a';julia> taylor(sin(A)^2, 0:1)1 + a * a + 2 * a' * a + a' * a'julia> taylor(sin(A)^2, 0:1) == A^2true

See also sin, cos, expim.

source
taylor(X::SuperExpr, ns)
taylor(L::Lindbladian{QExpr}, ns)

Lower every formal side of a map to its Maclaurin polynomial through order n, for ns = 0:n.

A SuperExpr becomes a SuperOperator and a Lindbladian{QExpr} a polynomial Lindbladian. Each formal function is expanded as for an operator.

source

The operator method of taylor takes an operator expression and an order range. It is distinct from the scalar method taylor(f, x, 0:n) of Symbolics, which expands in a variable x.

Numerical conversion

A formal function has no numerical form of its own. to_numeric, numeric_average, expect and average throw an ArgumentError on it rather than pick an expansion order silently, so the expression is lowered first.

using QuantumOpticsBasebackend = QuantumOpticsBackend()parameter = Dict(η => 0.1, Ω => 1.0, ν => 1.0)Hn = to_numeric(taylor(H, 0:2), h, (10, 2); backend, parameter)size(Hn)
(22, 22)

Matrix functions evaluated directly on the truncated space are not available yet (#268). A symbolic Σ over a formal function and conversion between normal and symmetric order with normal_to_symmetric and symmetric_to_normal are not supported either; both need the polynomial from taylor. Perturbative frame changes such as Schrieffer–Wolff or van Vleck transformations are a separate problem of effective Hamiltonians and are not part of the formal functions.