Hilbert Space#

Hilbert spaces for quantum mechanics.

Authors: * Brian Granger * Matt Curry

class sympy.physics.quantum.hilbert.ComplexSpace(dimension)[source]#

Finite dimensional Hilbert space of complex vectors.

The elements of this Hilbert space are n-dimensional complex valued vectors with the usual inner product that takes the complex conjugate of the vector on the right.

A classic example of this type of Hilbert space is spin-1/2, which is ComplexSpace(2). Generalizing to spin-s, the space is ComplexSpace(2*s+1). Quantum computing with N qubits is done with the direct product space ComplexSpace(2)**N.

Examples

>>> from sympy import symbols
>>> from sympy.physics.quantum.hilbert import ComplexSpace
>>> c1 = ComplexSpace(2)
>>> c1
C(2)
>>> c1.dimension
2
>>> n = symbols('n')
>>> c2 = ComplexSpace(n)
>>> c2
C(n)
>>> c2.dimension
n
class sympy.physics.quantum.hilbert.DirectSumHilbertSpace(*args)[source]#

A direct sum of Hilbert spaces [R690].

This class uses the + operator to represent direct sums between different Hilbert spaces.

A DirectSumHilbertSpace object takes in an arbitrary number of HilbertSpace objects as its arguments. Also, addition of HilbertSpace objects will automatically return a direct sum object.

Examples

>>> from sympy.physics.quantum.hilbert import ComplexSpace, FockSpace
>>> c = ComplexSpace(2)
>>> f = FockSpace()
>>> hs = c+f
>>> hs
C(2)+F
>>> hs.dimension
oo
>>> list(hs.spaces)
[C(2), F]

References

classmethod eval(args)[source]#

Evaluates the direct product.

property spaces#

A tuple of the Hilbert spaces in this direct sum.

class sympy.physics.quantum.hilbert.FockSpace[source]#

The Hilbert space for second quantization.

Technically, this Hilbert space is a infinite direct sum of direct products of single particle Hilbert spaces [R691]. This is a mess, so we have a class to represent it directly.

Examples

>>> from sympy.physics.quantum.hilbert import FockSpace
>>> hs = FockSpace()
>>> hs
F
>>> hs.dimension
oo

References

class sympy.physics.quantum.hilbert.HilbertSpace[source]#

An abstract Hilbert space for quantum mechanics.

In short, a Hilbert space is an abstract vector space that is complete with inner products defined [R692].

Examples

>>> from sympy.physics.quantum.hilbert import HilbertSpace
>>> hs = HilbertSpace()
>>> hs
H

References

property dimension#

Return the Hilbert dimension of the space.

class sympy.physics.quantum.hilbert.L2(interval)[source]#

The Hilbert space of square integrable functions on an interval.

An L2 object takes in a single SymPy Interval argument which represents the interval its functions (vectors) are defined on.

Examples

>>> from sympy import Interval, oo
>>> from sympy.physics.quantum.hilbert import L2
>>> hs = L2(Interval(0,oo))
>>> hs
L2(Interval(0, oo))
>>> hs.dimension
oo
>>> hs.interval
Interval(0, oo)
class sympy.physics.quantum.hilbert.TensorPowerHilbertSpace(*args)[source]#

An exponentiated Hilbert space [R693].

Tensor powers (repeated tensor products) are represented by the operator ** Identical Hilbert spaces that are multiplied together will be automatically combined into a single tensor power object.

Any Hilbert space, product, or sum may be raised to a tensor power. The TensorPowerHilbertSpace takes two arguments: the Hilbert space; and the tensor power (number).

Examples

>>> from sympy.physics.quantum.hilbert import ComplexSpace, FockSpace
>>> from sympy import symbols
>>> n = symbols('n')
>>> c = ComplexSpace(2)
>>> hs = c**n
>>> hs
C(2)**n
>>> hs.dimension
2**n
>>> c = ComplexSpace(2)
>>> c*c
C(2)**2
>>> f = FockSpace()
>>> c*f*f
C(2)*F**2

References

class sympy.physics.quantum.hilbert.TensorProductHilbertSpace(*args)[source]#

A tensor product of Hilbert spaces [R694].

The tensor product between Hilbert spaces is represented by the operator * Products of the same Hilbert space will be combined into tensor powers.

A TensorProductHilbertSpace object takes in an arbitrary number of HilbertSpace objects as its arguments. In addition, multiplication of HilbertSpace objects will automatically return this tensor product object.

Examples

>>> from sympy.physics.quantum.hilbert import ComplexSpace, FockSpace
>>> from sympy import symbols
>>> c = ComplexSpace(2)
>>> f = FockSpace()
>>> hs = c*f
>>> hs
C(2)*F
>>> hs.dimension
oo
>>> hs.spaces
(C(2), F)
>>> c1 = ComplexSpace(2)
>>> n = symbols('n')
>>> c2 = ComplexSpace(n)
>>> hs = c1*c2
>>> hs
C(2)*C(n)
>>> hs.dimension
2*n

References

classmethod eval(args)[source]#

Evaluates the direct product.

property spaces#

A tuple of the Hilbert spaces in this tensor product.