Skip to content

dq.momentum

momentum(dim: int, *, layout: Layout | None = None, hbar: float = 0.5) -> QArray

Returns the momentum operator \(p = i\sqrt{\hbar/2}\,(a^\dag - a)\).

Parameters:

  • dim –

    Dimension of the Hilbert space.

  • layout –

    Matrix layout (dq.dense, dq.dia or None).

  • hbar –

    Value of \(\hbar\) in the commutation relation \([\hat{x}, \hat{p}] = i\hbar\). Common choices are 0.5 (default), 1.0, and 2.0.

Returns:

  • (qarray of shape (dim, dim)) –

    Momentum operator.

Examples:

>>> dq.momentum(3)
QArray: shape=(3, 3), dims=(3,), dtype=complex64, layout=dia, ndiags=2
[[  â‹…       0.-0.5j     â‹…      ]
 [0.+0.5j     â‹…       0.-0.707j]
 [  â‹…       0.+0.707j   â‹…      ]]