from qiskit import *
from math import pi
import numpy as np
from qiskit.visualization import *
import matplotlib.pyplot as plt
from qutip import *

q = QuantumRegister(1)
qc = QuantumCircuit(q)
qc.h(0)
qc.draw(output='mpl')

backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()
print(result.get_unitary(qc, decimals=3))

q = QuantumRegister(1)
qc = QuantumCircuit(q)
qc.h(0)
qc.h(0)
qc.draw(output='mpl')

# Run the quantum circuit on a unitary simulator backend
backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()

# Show the results
print(result.get_unitary(qc, decimals=3))

H = np.array([[ 0.707+0.j,  0.707-0.j],[ 0.707+0.j, -0.707+0.j]])
np.dot(H,H)

q = QuantumRegister(1)
qc = QuantumCircuit(q)
qc.barrier()
qc0 = qc.copy()
qc.h(0)
qc.barrier()
qc1 = qc.copy()
qc.x(0)
qc.barrier()
qc2 = qc.copy()
qc.y(0)
qc.barrier()
qc3 = qc.copy()
qc.z(0)
qc.barrier()
qc4 = qc.copy()
qc.draw(output='mpl')

# Run the quantum circuit on a unitary simulator backend
backend = Aer.get_backend('unitary_simulator')
job = execute(qc, backend)
result = job.result()

# Show the results
print(result.get_unitary(qc, decimals=3))

X = sigmax()
Y = sigmay()
Z = sigmaz()
H = np.array([[ 0.707+0.j,  0.707-0.j],[ 0.707+0.j, -0.707+0.j]])
np.dot(np.dot(Z,Y),np.dot(X,H))

backend = Aer.get_backend('statevector_simulator')
for qc in [qc0,qc1,qc2,qc3,qc4]:
    out = execute(qc,backend).result().get_statevector()
    print(out)

