Bras and Kets
In bra-ket notation, vectors on a complex-valued Hilbert space are used to represent quantum states and operations. A column vector $|\psi\rangle$ is referred to as a ket whereas a row vector $\langle \psi|$ is referred to as a bra. Bras and kets are dual to each other via the adjoint operation. That is, $\langle\psi| = |\psi\rangle^{\dagger}$ and $|\psi\rangle = \langle\psi|^{\dagger}$.
Quantum systems behave probabilistically under observation, hence quantum mechanics is used to construct probability distributions which describe the behavior of quantum systems. For this reason, bras and kets must be normalized such that $\langle\psi|\psi\rangle = 1$ holds true. Here $\langle \cdot | \cdot \rangle$ denotes the inner product (dot product) between bra and ket. These constraints are checked with the following method.
QBase.is_braket — Functionis_braket( ψ :: Vector; atol=ATOL :: Float64) :: Bool
is_braket(
ψ :: Adjoint{T, Vector{T}};
atol=ATOL :: Float64
) where T <: Number :: BoolReturns true if vector ψ is a valid bra (or ket):
ψis a real or complex-valued vector.ψis normalized with respect to the bra-ket inner prodcut (ψ' * ψ == 1).
Bra-Ket Types
QBase.Ket — TypeKet(ψ :: Vector{T}; atol=ATOL :: Float64) where T <: NumberA normalized column vector on a complex-valued Hilbert space. If called with an adjoint vector ψ', the adjoint will be taken on construction.
Ket(ψ :: Adjoint{Vector{T}}; atol=ATOL :: Float64) where T <: NumberSimilarly a Bra can be converted into a Ket via the adjoint.
Ket(ψ :: Bra{T}; atol=ATOL :: Float64) where T <: NumberKet(ψ), throws a DomainError if ψ is not normalized.
QBase.Bra — TypeBra(ψ :: Adjoint{T,Vector{T}}; atol=ATOL :: Float64) where T <: NumberA row vector on a complex valued HIlbet space. Bras are dual to Kets via the adjoint If called with an Vector{<:Number} type, the adjoint will automatically be taken ψ'.
Bra(ψ :: Vector{<:Number}; atol=ATOL :: Float64)Similarly a Ket can be converted into a Bra via the adjoint.
Bra(ψ :: Ket; atol=ATOL :: Float64)Bra(ψ'), throws a DomainError if ψ' is not normalized.
Bra-Ket Algebra
Base.:* — MethodOuter product $|\psi \rangle\langle \psi|$:
*(ket :: Ket, bra :: Bra) :: MatrixInner product $\langle \psi | \psi \rangle$:
*(bra :: Bra, ket :: Ket) :: NumberBase.adjoint — MethodThe adjoint is the complex conjugate transpose. This operation converts a Ket to a Bra, $\langle \psi | = |\psi \rangle^{\dagger}$:
adjoint(ket :: Ket) :: BraOr, convert a Bra to a Ket, $|\psi\rangle = \langle \psi |^{\dagger}$:
adjoint(bra :: Bra) :: KetBase.kron — MethodPerforms the kronecker product of a set of Kets (Bras) to produce a new Ket (Bra).
kron( kets :: Vararg{Ket}; atol=ATOL ) :: Ket
kron( bras :: Vararg{Bra}; atol=ATOL ) :: BraKet Constructors
QBase.jl provides a catalog for constructing various Kets. To construct similar Bras you must manually convert the Ket to a Bra using either adjoint(::Ket) or Bra(::Ket).
Ket Singlets
QBase.bloch_qubit_ket — Functionbloch_qubit_ket( θ :: Real, ϕ :: Real ) :: Ket{Complex{Float64}}Returns the qubit ket for the specified spherical coordinate on the surface of bloch sphere, (r=1, θ, ϕ):
\[|\psi\rangle = \cos(\theta/2)|0\rangle + e^{i\phi}\sin(\theta/2)|1\rangle\]
If the ket does not have a phase then a real-valued Ket is constructed as:
bloch_qubit_ket( θ :: Real ) :: Ket{Float64}Inputs:
θ ∈ [0, 2π]: polar angle (w.r.t z-axis)ϕ ∈ [0, 2π]: azimuthal angle (x-y plane)
A DomainError is thrown if inputs θ and/or ϕ do are not within the valid range.
Ket Ensembles
QBase.computational_basis_kets — Functioncomputational_basis_kets( dim :: Int64 ) :: Vector{Ket{Int64}}The computational basis vectors for the Hilbert space of dimension, dim.
\[\Psi = \{ |j\rangle \}_{j=0}^{(d-1)}\]
QBase.bell_kets — Functionbell_kets() :: Vector{Ket{Float64}}The Bell basis kets for maximally entangled bipartite qubit systems. These kets are ordered as $\{|\Phi^+\rangle, |\Phi^-\rangle, |\Psi^+\rangle, |\Psi^-\rangle \}$, where
\[\begin{matrix} |\Phi^+\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle), & |\Phi^-\rangle = \frac{1}{\sqrt{2}}(|00\rangle - |11\rangle), \\ |\Psi^+\rangle = \frac{1}{\sqrt{2}}(|01\rangle + |10\rangle), & |\Psi^-\rangle = \frac{1}{\sqrt{2}}(|01\rangle - |10\rangle). \\ \end{matrix}\]
QBase.generalized_bell_kets — Functiongeneralized_bell_kets( dim :: Int64 ) :: Vector{Ket{Float64}}The Bell basis for entangled bipartite quantum states each of dimension dim. Each state is constructed by
\[|\Psi^p_c\rangle = \frac{1}{\sqrt{d}}\sum_{j=0}^{d-1} e^{i2\pi pj/d}|j\rangle |\mod(j+c,d)\rangle\]
where $p,c\in \{0,\cdots, (d-1)\}$ and $d$ is dim. When iterated, $c$ is the major index and $p$ is the minor index.
A DomainError is thrown if dim ≥ 2 is not satisfied.
QBase.mirror_symmetric_qubit_kets — Functionmirror_symmetric_qubit_kets( θ :: Real ) :: Vector{Ket{Float64}}Returns the triplet of qubit kets in the x-z plane of bloch sphere. The first ket is $|0\rangle$ and the other two are symmetric across the z-axis, $|\pm\rangle = \cos(\theta)|0 \rangle \pm \sin(\theta)|1\rangle$.
Input:
θ ∈ [0,π/2]: the hilbert space angle between $|0\rangle$ and symmetric kets.
QBase.planar_symmetric_qubit_kets — Functionplanar_symmetric_qubit_kets( n :: Int64 ) :: Vector{Ket{Float64}}Constructs a set of nKets oriented symmetrically in the x-z-plane. Each ket is separated by a bloch angle of 2π/n. The Kets are constructed with the form:
\[|\psi_j \rangle = \cos(j \pi/n) | 0\rangle + \sin(j \pi/n)|1\rangle\]
where $j \in \{0,\cdots, (n-1)\}$.
A DomainError is thrown if n < 2.
QBase.trine_qubit_kets — Functiontrine_qubit_kets() :: Vector{Ket{Float64}}The triplet of Kets separated by equal angles in the x-z plane of bloch sphere.
\[ |\psi_1\rangle = |0\rangle, \quad |\psi_2\rangle = \frac{1}{2}|0\rangle + \frac{\sqrt{3}}{2}|1\rangle, \quad |\psi_3\rangle = \frac{1}{2}|0\rangle - \frac{\sqrt{3}}{2}|1\rangle\]
QBase.sic_qubit_kets — Functionsic_qubit_kets() :: Vector{Ket{Complex{Float64}}}The quadruplet of symmetric informationally complete (SIC) qubits. This set of qubits correspond to the vertices of a tetrahedron inscribed on bloch sphere.
\[\begin{matrix} |\psi_1\rangle = |0\rangle, & \quad |\psi_2\rangle = \frac{1}{\sqrt{3}}|0\rangle + \sqrt{\frac{2}{3}}|1\rangle, \\ |\psi_3\rangle = \frac{1}{\sqrt{3}}|0\rangle + \sqrt{\frac{2}{3}} e^{i 2\pi/3}|1\rangle, & \quad |\psi_4\rangle = \frac{1}{\sqrt{3}}|0\rangle + \sqrt{\frac{2}{3}} e^{i 4\pi/3}|1\rangle \end{matrix}\]
QBase.bb84_qubit_kets — Functionbb84_qubit_kets :: Vector{Ket{Float64}}The quadruplet of qubit kets used in the BB84 Quantum Key Distribution protocol. The states are $|0\rangle$, $|+\rangle$, $|1\rangle$, and $|- \rangle$.