How to find angle for Pauli-Z in U3

What are the angles (lambda, phi and theta) for Pauli-Z gate in U3 ?

• related: quantumcomputing.stackexchange.com/q/6236/55. If that doesn't answer your question, please provide more context and details (by editing the question accordingly, not in the comments). For example, what do you mean exactly with "find angle" here?
– glS
Oct 31 at 9:25

2 Answers

You can use OneQubitEulerDecomposer class as follows:

from qiskit.circuit.library import ZGate
from qiskit.quantum_info import OneQubitEulerDecomposer

decomposer = OneQubitEulerDecomposer('U3')

theta, phi, _lambda = decomposer.angles(ZGate().to_matrix())
print(theta, phi, _lambda)

• I like this solution! Nov 1 at 8:28

You can turn rewrite your Pauli-Z into a U3 with transpile:

from qiskit import transpile
from qiskit.opflow import Z
circuit_u3 = transpile(Z.to_circuit(), basis_gates=['u3'])
circuit_u3.draw()

   ┌───────────┐
q: ┤ U3(0,0,π) ├
└───────────┘


There you have the $$\texttt{U3}(\theta, \phi, \lambda)$$, $$\theta=0$$, $$\phi=0$$, and $$\lambda=\pi$$.