Logic for applying operators to states.

Todo: * Sometimes the final result needs to be expanded, we should do this by hand.

sympy.physics.quantum.qapply.qapply(e, **options)[source]

Apply operators to states in a quantum expression.


e : Expr

The expression containing operators and states. This expression tree will be walked to find operators acting on states symbolically.

options : dict

A dict of key/value pairs that determine how the operator actions are carried out.

The following options are valid:

  • dagger: try to apply Dagger operators to the left (default: False).
  • ip_doit: call .doit() in inner products when they are encountered (default: True).

e : Expr

The original expression, but with the operators applied to states.


>>> from sympy.physics.quantum import qapply, Ket, Bra
>>> b = Bra('b')
>>> k = Ket('k')
>>> A = k * b
>>> A
>>> qapply(A * b.dual / (b * b.dual))
>>> qapply(k.dual * A / (k.dual * k), dagger=True)
>>> qapply(k.dual * A / (k.dual * k))