States
QBase.States
— ModuleThe States
submodule provides:
abstract
andconcrete
types for quantum state representations.- A catalog of constructors for instantiating quantum states.
In discrete and finite quantum systems, states can be represented computationally with vectors (Bra-Ket Representation) or matrices (Density Matrix Representation).
Bra-Ket Representation
A quantum state is represented by a vector on a complex-valued Hilbert space. In Bra-Ket notation, a quantum state denoted $|\psi\rangle$ is referred to as a ket and is simply understood as a column vector. Each ket has an associated dual vector known as a bra. A bra is may be represented by a row vector and can be constructed from a ket via Hermitian adjoint, $\langle\psi| = (|\psi\rangle)^{\dagger}$.
It is essential that a quantum states are normalized, $\langle\psi|\psi\rangle = 1$, where $\langle \; | \; \rangle$ denotes the inner product (dot product) between bra and ket.
The States
module provides a validation method, is_ket()
for checking whether a vector satisfies the requirements for being a quantum state ket.
QBase.States.is_ket
— Functionis_ket( ψ :: Vector ) :: Bool
Returns true
if vector ψ
is a valid ket representation of a quamtum state:
ψ
is a real or complex-valued vector.ψ
is normalized with respect to the bra-ket inner prodcut (ψ' * ψ == 0
).
Ket Types
QBase.States.AbstractKet
— TypeAbstractKet <: AbstractVector{Complex{Float64}}
The abstract type representing a quantum state ket. Since kets are contained within a complex-valued hilbert space, they are appropriately AbstractVector{Complex{Float64}}
subtypes. An AbstractKet
cannot be instantiated, it serves as a supertype from which ket types are defined.
An AbstractKet
subtype may be operated upon by a AbstractUnitary
subtype to produce a new Ket
.
*( U :: Unitaries.AbstractUnitary, ψ :: AbstractKet) :: Ket
The States
module provides two concrete subtypes of AbstractKet
:
QBase.States.Ket
— TypeKet( ψ :: Vector{Complex{Float64}} ) <: AbstractKet
A ket representation of a general quantum state. When given invalid input, the constructor, Ket(ψ)
, throws:
DomainError
- Ifψ
is not normalized.MethodError
- Ifψ
is not a column vector ([a,b,c]
or[a;b;c]
)
QBase.States.QubitKet
— TypeQubitKet( ψ :: Vector{Complex{Float64}} ) <: AbstractKet
A ket representation of a 2-dimensional quantum state. When given invalid input, the constructor, QubitKet(ψ)
, throws:
DomainError
- Ifψ
is not normalized.MethodError
- Ifψ
is not a column vector.
Ket Constructors
QBase.States.basis_kets
— Functionbasis_kets( dim :: Int64 ) :: Vector{Ket}
The computation basis vectors for a hilbert space of dimension, dim
.
QBase.States.bell_kets
— Constantbell_kets :: Vector{Ket}
The Bell basis kets, ordered as $\{|\Phi^+\rangle, |\Phi^-\rangle, |\Psi^+\rangle, |\Psi^-\rangle \}$, where
QBase.States.generalized_bell_kets
— Functiongeneralized_bell_kets( dim :: Int64 ) :: Vector{Ket}
The Bell basis for quantum states of dimension dim
. Each state is constructed by
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.
Singlet States
QBase.States.bloch_qubit_ket
— Functionbloch_qubit_ket( θ :: Real, ϕ :: Real ) :: QubitKet
Returns the qubit ket for the specified spherical coordinate on the surface of bloch sphere, (r=1, θ, ϕ)
. If the state does not have a complex phase then
bloch_qubit_ket( θ :: Real ) :: QubitKet
can be used to construct the state.
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.
Triplet States
QBase.States.trine_qubit_kets
— Constanttrine_qubit_kets :: Vector{QubitKet}
The triplet of kets representing three quantum states separated by equal angles in the z-x plane of bloch sphere.
julia> States.trine_qubit_kets == [[1.0, 0], [0.5, sqrt(3)/2], [0.5, -sqrt(3)/2]]
true
QBase.States.mirror_symmetric_qubit_kets
— Functionmirror_symmetric_qubit_kets( θ :: Real ) :: Vector{QubitKet}
Returns the triplet of qubit kets in the z-x plane of bloch sphere. The first ket is $|0\rangle$ and the other two are symmetric across the z-axis.
Input:
θ ∈ [0,π/2]
: the hilbert space angle between |0> and symmetric kets.
QBase.States.planar_symmetric_qubit_kets
— Functionplanar_symmetric_qubit_kets( n :: Int64 ) :: Vector{QubitKet}
Constructs a set of QubitKet
states oriented symmetrically in the x-z-plane. Each state is separated by a bloch angle of 2π/n
. The states are constructed with the form
where $j \in 0,\cdots, (n-1)$.
A DomainError
is thrown if
Density Matrix Representation
Quantum states can be represented in matrix form.
QBase.States.is_density_matrix
— Functionis_density_matrix( ρ :: Matrix ) :: Bool
Returns true if input ho
is:
- Hermitian
- Positive Semi-Definite
- Trace[ρ] = 1 (normalization)
QBase.States.AbstractDensityMatrix
— TypeAbstractDensityMatrix <: AbstractMatrix{Complex{Float64}}
The abstract type representing all density matrices.
QBase.States.DensityMatrix
— TypeDensityMatrix( ρ :: Matrix{Complex{Float64}} ) <: AbstractDensityMatrix
The density matrix representation of a quantum state. The constructor, DensityMatrix(ρ)
throws a DomainError
if is_density_matrix(ρ)
is false
.
Base methods extended to use the DensityMatrix
type:
QMath.partial_trace
- ReturnsDensityMatrix
if supplied with one.Base.kron
- The kronecker product of two density matrices is aDensityMatrix
.
QBase.States.Qubit
— TypeQubit( ρ :: Matrix{Complex{Float64}} ) <: AbstractDensityMatrix
The 2x2 density matrix representation of a qubit. The constructor, Qubit(ρ)
throws a DomainError
if is_density_matrix(ρ)
is false or if ρ
is not 2x2 in dimension.
Density Matrix Constructors
The density matrix $\rho$ can be constructed from ket $|\psi\rangle$ by taking the outer-product of the ket with itself, $|\psi\rangle\langle\psi| = \rho$.
QBase.States.pure_state
— Functionpure_state( ψ :: AbstractKet ) :: Qubit
A state is considered "pure" if it is rank-one. A rank-one density matrix is constructed by taking the outer-product of a ket state.
The method alternatively accepts a Vector
input.
pure_state( ψ :: Vector ) :: Qubit
A DomainError
is thrown if ψ
is not a valid ket.
QBase.States.pure_qubit
— Functionpure_qubit( ψ :: AbstractKet ) :: Qubit
A qubit is considered "pure" if it is rank-one. A rank-one density matrix is constructed by taking the outer-product of a ket state.
The method alternatively accepts a Vector
input.
pure_qubit( ψ :: Vector ) :: Qubit
A DomainError
is thrown if ψ
is not a valid ket.`
QBase.States.basis_states
— Functionbasis_states( dim :: Int64 ) :: Vector{DensityMatrix}
The density matrices for the computational basis of dimension, dim
.
QBase.States.bell_states
— Constantbell_states :: Vector{DensityMatrix}
The Bell basis density matrices. See States.bell_kets
for more details.
QBase.States.generalized_bell_states
— Functiongeneralized_bell_states( dim :: Int64 ) :: Vector{DensityMatrix}
The density matrix representation of the generalized Bell basis. See States.bell_kets
for more details.
A DomainError
is thrown if dim ≥ 2
is not satisfied.
QBase.States.planar_symmetric_qubits
— Functionplanar_symmetric_qubits( n :: Int64 ) :: Vector{Qubit}
Constructs a set of Qubit
pure states oriented symmetrically in the x-z-plane. See planar_symmetric_qubit_kets
for details.
The rank of the density matrix can be greater than 1. If a density matrix has rank greater than one, we call the state mixed.
QBase.States.mixed_state
— Functionmixed_state(
priors :: QMath.Marginals,
ρ_states :: Vector{<:AbstractDensityMatrix}
) :: DensityMatrix
Constructs the statistical mixture (weighted average) of quantum states. The method accepts states as type DensityMatrix
or subbtypes AbstractDensityMatrix
.
QBase.States.mixed_qubit
— Functionmixed_qubit( priors :: QMath.Marginals, ρ_states :: Vector{Qubit} ) :: Qubit
Constructs the statistical mixture (weighted average) of qubits.
QBase.States.bloch_qubit
— FunctionReturns the qubit density matrix for quantum state described by a coordinate on bloch sphere.
Spherical Coordinates:
States on the surface of bloch sphere may be described by spherical coordinates.
bloch_qubit(θ::Real, ϕ::Real) :: Qubit
θ ∈ [0, π]
: polar angle (w.r.t z-axis).ϕ ∈ [0, 2π]
: azimuthal angle (x-y plane)
Cartesian Coordinates:
States within the volume of bloch sphere may be described in cartesian coordinates.
bloch_qubit(x::Real, y::Real, z::Real) :: Qubit
- where
x
,y
, andz
are constrained to the unit sphere,0 <= norm([x,y,z]) <= 1
.
A DomainError
is thrown if the coordinates (x,y,z)
do not adhere to constraints.
Triplets
QBase.States.trine_qubits
— Constanttrine_qubits :: Vector{Qubit}
Returns the qubit trine states in density matrix form.
QBase.States.mirror_symmetric_qubits
— Functionmirror_symmetric_qubits( θ :: Real ) :: Vector{Qubit}
Returns a set of 3 mirror symmetric qubit density matrices. The first state is $|0\rangle\langle 0|$ the other two are symmetric about the $|0\rangle$ axis.
Input:
θ ∈ [0,π/2]
: the hilbert space angle between $|0\rangle$ and $|\psi_{2/3}\rangle$.
Quadruplets
QBase.States.sic_qubits
— Constantsic_qubits :: Vector{Qubit}
The quadruplet of symmetric informationally complete (SIC) qubits. The qubits are the vertices of a tetrahedron inscribed on bloch sphere.
julia> States.sic_qubits
4-element Array{QBase.States.Qubit,1}:
[1.0 + 0.0im 0.0 + 0.0im; 0.0 + 0.0im 0.0 + 0.0im]
[0.33333333333333337 + 0.0im 0.47140452079103173 + 0.0im; 0.47140452079103173 + 0.0im 0.6666666666666666 + 0.0im]
[0.33333333333333337 + 0.0im -0.2357022603955158 - 0.4082482904638631im; -0.2357022603955158 + 0.4082482904638631im 0.6666666666666666 + 0.0im]
[0.33333333333333337 - 0.0im -0.2357022603955158 + 0.4082482904638631im; -0.2357022603955158 - 0.4082482904638631im 0.6666666666666666 - 0.0im]
QBase.States.bb84_qubits
— Constantbb84_qubits :: Vector{Qubit}
The quadruplet of qubits used in the BB84 Quantum Key Distribution protocol. The states are $|0\rangle\langle 0|$, $|1\rangle\langle 1|$, $|+\rangle\langle +|$, and $|- \rangle\langle -|$.
julia> States.bb84_qubits
4-element Array{QBase.States.Qubit,1}:
[1.0 + 0.0im 0.0 + 0.0im; 0.0 + 0.0im 0.0 + 0.0im]
[0.0 + 0.0im 0.0 + 0.0im; 0.0 + 0.0im 1.0 + 0.0im]
[0.5 + 0.0im 0.5 + 0.0im; 0.5 + 0.0im 0.5 + 0.0im]
[0.5 + 0.0im -0.5 + 0.0im; -0.5 + 0.0im 0.5 + 0.0im]