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 $$\sigma_- = \frac{1}{2}(\sigma_x + i\sigma_y)$$. 'P' creates the raising matrix $$\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

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 = qctrl.functions.calculate_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]])


Create the Pauli Y matrix.

>>> graph.pauli_matrix("Y", name="sigma_y")
<Tensor: name="sigma_y", operation_name="pauli_matrix", shape=(2, 2)>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["sigma_y"])
>>> result.output["sigma_y"]["value"]
array([[0.+0.j, 0.-1.j],
[0.+1.j, 0.+0.j]])


Create the Pauli lowering matrix.

>>> graph.pauli_matrix("M", name="sigma_m")
<Tensor: name="sigma_m", operation_name="pauli_matrix", shape=(2, 2)>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["sigma_m"])
>>> result.output["sigma_m"]["value"]
array([[0.+0.j, 1.+0.j],
[0.+0.j, 0.+0.j]])


Create the identity.

>>> graph.pauli_matrix("I", name="identity")
<Tensor: name="identity", operation_name="pauli_matrix", shape=(2, 2)>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["identity"])
>>> result.output["identity"]["value"]
array([[1.+0.j, 0.+0.j],
[0.+0.j, 1.+0.j]])