pauli_matrix

Graph.pauli_matrix(label, *, name=None)

Create a Pauli matrix from a label.

Parameters

  • label (str) – The string that indicates which Pauli matrix to create. Must be 'I', 'X', 'Y', 'Z', 'M', or 'P'. 'M' creates the lowering matrix σ=12(σx+iσy)\sigma_- = \frac{1}{2}(\sigma_x + i\sigma_y). 'P' creates the raising matrix σ+=12(σxiσy)\sigma_+ = \frac{1}{2}(\sigma_x - i\sigma_y). We use the convention |\downarrow\rangle = \begin{bmatrix}1\0\end{bmatrix} and |\uparrow\rangle = \begin{bmatrix}0\1\end{bmatrix}.
  • name (str or None , optional) – The name of the node.

Returns

The Pauli matrix.

Return type

Tensor

SEE ALSO

Graph.pauli_kronecker_product : Embed Pauli matrices into a larger Hilbert space.

Examples

Create the Pauli X matrix.

>>> graph.pauli_matrix("X", name="sigma_x")
<Tensor: name="sigma_x", operation_name="pauli_matrix", shape=(2, 2)>
>>> result = bo.execute_graph(graph=graph, output_node_names="sigma_x")
>>> result["output"]["sigma_x"]["value"]
array([[0.+0.j, 1.+0.j],
       [1.+0.j, 0.+0.j]])

Was this useful?