Operator¶
Quantum mechanical operators.
TODO:
 Fix early 0 in apply_operators.
 Debug and test apply_operators.
 Get cse working with classes in this file.
 Doctests and documentation of special methods for InnerProduct, Commutator, AntiCommutator, represent, apply_operators.

class
sympy.physics.quantum.operator.
Operator
[source]¶ Base class for noncommuting quantum operators.
An operator maps between quantum states [R480]. In quantum mechanics, observables (including, but not limited to, measured physical values) are represented as Hermitian operators [R481].
Parameters: args : tuple
The list of numbers or parameters that uniquely specify the operator. For timedependent operators, this will include the time.
References
[R480] (1, 2) http://en.wikipedia.org/wiki/Operator_%28physics%29 [R481] (1, 2) http://en.wikipedia.org/wiki/Observable Examples
Create an operator and examine its attributes:
>>> from sympy.physics.quantum import Operator >>> from sympy import symbols, I >>> A = Operator('A') >>> A A >>> A.hilbert_space H >>> A.label (A,) >>> A.is_commutative False
Create another operator and do some arithmetic operations:
>>> B = Operator('B') >>> C = 2*A*A + I*B >>> C 2*A**2 + I*B
Operators don’t commute:
>>> A.is_commutative False >>> B.is_commutative False >>> A*B == B*A False
Polymonials of operators respect the commutation properties:
>>> e = (A+B)**3 >>> e.expand() A*B*A + A*B**2 + A**2*B + A**3 + B*A*B + B*A**2 + B**2*A + B**3
Operator inverses are handle symbolically:
>>> A.inv() A**(1) >>> A*A.inv() 1

class
sympy.physics.quantum.operator.
HermitianOperator
[source]¶ A Hermitian operator that satisfies H == Dagger(H).
Parameters: args : tuple
The list of numbers or parameters that uniquely specify the operator. For timedependent operators, this will include the time.
Examples
>>> from sympy.physics.quantum import Dagger, HermitianOperator >>> H = HermitianOperator('H') >>> Dagger(H) H

class
sympy.physics.quantum.operator.
UnitaryOperator
[source]¶ A unitary operator that satisfies U*Dagger(U) == 1.
Parameters: args : tuple
The list of numbers or parameters that uniquely specify the operator. For timedependent operators, this will include the time.
Examples
>>> from sympy.physics.quantum import Dagger, UnitaryOperator >>> U = UnitaryOperator('U') >>> U*Dagger(U) 1

class
sympy.physics.quantum.operator.
IdentityOperator
(*args, **hints)[source]¶ An identity operator I that satisfies op * I == I * op == op for any operator op.
Parameters: N : Integer
Optional parameter that specifies the dimension of the Hilbert space of operator. This is used when generating a matrix representation.
Examples
>>> from sympy.physics.quantum import IdentityOperator >>> IdentityOperator() I

class
sympy.physics.quantum.operator.
OuterProduct
[source]¶ An unevaluated outer product between a ket and bra.
This constructs an outer product between any subclass of
KetBase
andBraBase
asa><b
. AnOuterProduct
inherits from Operator as they act as operators in quantum expressions. For reference see [R482].Parameters: ket : KetBase
The ket on the left side of the outer product.
bar : BraBase
The bra on the right side of the outer product.
References
[R482] (1, 2) http://en.wikipedia.org/wiki/Outer_product Examples
Create a simple outer product by hand and take its dagger:
>>> from sympy.physics.quantum import Ket, Bra, OuterProduct, Dagger >>> from sympy.physics.quantum import Operator >>> k = Ket('k') >>> b = Bra('b') >>> op = OuterProduct(k, b) >>> op k><b >>> op.hilbert_space H >>> op.ket k> >>> op.bra <b >>> Dagger(op) b><k
In simple products of kets and bras outer products will be automatically identified and created:
>>> k*b k><b
But in more complex expressions, outer products are not automatically created:
>>> A = Operator('A') >>> A*k*b A*k>*<b
A user can force the creation of an outer product in a complex expression by using parentheses to group the ket and bra:
>>> A*(k*b) A*k><b

bra
¶ Return the bra on the right side of the outer product.

ket
¶ Return the ket on the left side of the outer product.


class
sympy.physics.quantum.operator.
DifferentialOperator
[source]¶ An operator for representing the differential operator, i.e. d/dx
It is initialized by passing two arguments. The first is an arbitrary expression that involves a function, such as
Derivative(f(x), x)
. The second is the function (e.g.f(x)
) which we are to replace with theWavefunction
that thisDifferentialOperator
is applied to.Parameters: expr : Expr
The arbitrary expression which the appropriate Wavefunction is to be substituted into
func : Expr
A function (e.g. f(x)) which is to be replaced with the appropriate Wavefunction when this DifferentialOperator is applied
Examples
You can define a completely arbitrary expression and specify where the Wavefunction is to be substituted
>>> from sympy import Derivative, Function, Symbol >>> from sympy.physics.quantum.operator import DifferentialOperator >>> from sympy.physics.quantum.state import Wavefunction >>> from sympy.physics.quantum.qapply import qapply >>> f = Function('f') >>> x = Symbol('x') >>> d = DifferentialOperator(1/x*Derivative(f(x), x), f(x)) >>> w = Wavefunction(x**2, x) >>> d.function f(x) >>> d.variables (x,) >>> qapply(d*w) Wavefunction(2, x)

expr
¶ Returns the arbitrary expression which is to have the Wavefunction substituted into it
Examples
>>> from sympy.physics.quantum.operator import DifferentialOperator >>> from sympy import Function, Symbol, Derivative >>> x = Symbol('x') >>> f = Function('f') >>> d = DifferentialOperator(Derivative(f(x), x), f(x)) >>> d.expr Derivative(f(x), x) >>> y = Symbol('y') >>> d = DifferentialOperator(Derivative(f(x, y), x) + ... Derivative(f(x, y), y), f(x, y)) >>> d.expr Derivative(f(x, y), x) + Derivative(f(x, y), y)

free_symbols
¶ Return the free symbols of the expression.

function
¶ Returns the function which is to be replaced with the Wavefunction
Examples
>>> from sympy.physics.quantum.operator import DifferentialOperator >>> from sympy import Function, Symbol, Derivative >>> x = Symbol('x') >>> f = Function('f') >>> d = DifferentialOperator(Derivative(f(x), x), f(x)) >>> d.function f(x) >>> y = Symbol('y') >>> d = DifferentialOperator(Derivative(f(x, y), x) + ... Derivative(f(x, y), y), f(x, y)) >>> d.function f(x, y)

variables
¶ Returns the variables with which the function in the specified arbitrary expression is evaluated
Examples
>>> from sympy.physics.quantum.operator import DifferentialOperator >>> from sympy import Symbol, Function, Derivative >>> x = Symbol('x') >>> f = Function('f') >>> d = DifferentialOperator(1/x*Derivative(f(x), x), f(x)) >>> d.variables (x,) >>> y = Symbol('y') >>> d = DifferentialOperator(Derivative(f(x, y), x) + ... Derivative(f(x, y), y), f(x, y)) >>> d.variables (x, y)
