from qiskit import *
from qiskit.extensions import *
from qiskit.quantum_info import Statevector,Operator
from math import pi
from qiskit.visualization import *

qc = QuantumCircuit(1)
qc.u(pi/2,pi/2,pi/2,0)
qc.draw(output="mpl")

backend = Aer.get_backend('unitary_simulator')

job = execute(qc, backend)
result = job.result()
#Obtain the unitary matrix for U gate
Ugate_unitary=result.get_unitary(qc, decimals=3)
print(Ugate_unitary)

Ugate_unitary.data

array_to_latex(Ugate_unitary)

array_to_latex(Operator(UGate(pi/2,pi/2,pi/2)).data)

qc = QuantumCircuit(1)
qc.u(pi/2,0,pi,0)
qc.draw(output="mpl")

job = execute(qc, backend)
result = job.result()
#Obtain the unitary matrix for U gate
Ugate_unitary=result.get_unitary(qc, decimals=3)
print(Ugate_unitary)

array_to_latex(Ugate_unitary)

array_to_latex(Operator(UGate(pi/2,0,pi)).data)

array_to_latex(Operator(HGate()).data)

qc = QuantumCircuit(1)
qc.u(0,0,pi/2,0)
qc.draw(output="mpl")

job = execute(qc, backend)
result = job.result()
#Obtain the unitary matrix for U gate
Ugate_unitary=result.get_unitary(qc, decimals=3)
print(Ugate_unitary)

array_to_latex(Ugate_unitary)

array_to_latex(Operator(UGate(0,0,pi/2)).data)

array_to_latex(Operator(PhaseGate(pi/2)).data)

array_to_latex(Operator(UGate(pi/2,0,0)).data)

array_to_latex(Operator(RYGate(pi/2)).data)

array_to_latex(Operator(UGate(0,pi/2,-pi/2)).data)

array_to_latex(Operator(RXGate(0)).data)

