# Here we are importing all packages from qiskit
from qiskit import *
from qiskit.circuit import Parameter
from math import pi

# define the number of qubits
num_q = 3
theta = Parameter('θ')
# Here create the quantum circuit
qc = QuantumCircuit(num_q)

# Here we apply the Rz gate to the ith-qubit
for i in range(num_q):
    qc.rz(theta,i)

# Here we draw the quantum circuit
qc.draw(output='mpl')

# define the number of qubits
num_q = 3
# Here create the quantum circuit with one qubit
qc = QuantumCircuit(num_q)

# Here we apply the Rz, Rx, and Ry gates to the ith-qubit
for i in range(num_q):
    qc.rz(theta,i)
    qc.ry(theta,i)
    qc.rx(theta,i)
    
qc.barrier()

# Here we draw the quantum circuit
qc.draw(output='mpl')

# define the number of qubits
num_q = 5
# Here create the quantum circuit with one qubit
qc = QuantumCircuit(num_q)
phi = Parameter('φ')
# Here is the loop that applies the Rz, Rx, and Ry gates to the ith-qubit
for i in range(num_q):
    qc.rz(theta,i)
    qc.ry(theta,i)
    qc.rx(theta,i)
# Here is the loop that applies the CNOTxRzxCNOT gates    
for i in range(num_q-1):
    qc.cx(i,i+1)
    qc.rz(phi,i+1)
    qc.cx(i,i+1)           
    
qc.barrier()

# Here we draw the quantum circuit
qc.draw(output='mpl')

# define the number of qubits
num_q = 5
# Here create the quantum circuit with one qubit
qc = QuantumCircuit(num_q)

# Here is the loop that applies the Rz, Rx, and Ry gates to the ith-qubit
for i in range(num_q):
    qc.rz(theta,i)
    qc.ry(theta,i)
    qc.rx(theta,i)
# Implementation of even interactions    
for i in range(num_q-1):
    if ((i%2)==0 and (i <= (num_q)-2)):
        qc.cx(i,i+1)
        qc.rz(phi,i+1)
        qc.cx(i,i+1)
# Implementation of the odd interactions  
for i in range(num_q-1):
    if ((i%2)==1 and (i <= (num_q)-2)):
        qc.cx(i,i+1)
        qc.rz(phi,i+1)
        qc.cx(i,i+1)           
    
qc.barrier()

# Here we draw the quantum circuit
qc.draw(output='mpl')

# define the number of qubits
num_q = 5
# Here create the quantum circuit with one qubit
qc = QuantumCircuit(num_q)

# Here is the loop that applies the Rz, Rx, and Ry gates to the ith-qubit
for i in range(num_q):
    qc.rz(theta,i)
    qc.ry(theta,i)
    qc.rx(theta,i)
    
qc.barrier()
# Implementation of even interactions    
for i in range(num_q-1):
    if ((i%2)==0 and (i <= (num_q)-2)):
        qc.cx(i,i+1)
        qc.rz(phi,i+1)
        qc.cx(i,i+1)
        qc.cx(i,i+1)
        qc.ry(phi,i+1)
        qc.cx(i,i+1)
        qc.cx(i,i+1)
        qc.rx(phi,i+1)
        qc.cx(i,i+1)
        
qc.barrier()
# Implementation of the odd interactions
for i in range(num_q-1):
    if ((i%2)==1 and (i <= (num_q)-2)):
        qc.cx(i,i+1)
        qc.rz(phi,i+1)
        qc.cx(i,i+1)
        qc.cx(i,i+1)
        qc.ry(phi,i+1)
        qc.cx(i,i+1)
        qc.cx(i,i+1)
        qc.rx(phi,i+1)
        qc.cx(i,i+1)          
    
qc.barrier()

# Here we draw the quantum circuit
qc.draw(output='mpl')

# define the number of qubits
num_q = 5
# Here create the quantum circuit with one qubit
qc = QuantumCircuit(num_q)

# Here is the loop that applies the Rz, Rx, and Ry gates to the ith-qubit
for i in range(num_q):
    qc.rz(theta,i)
    qc.ry(theta,i)
    qc.rx(theta,i)
    
qc.barrier()
# Implementation of even interactions    
for i in range(num_q-1):
    if ((i%2)==0 and (i <= (num_q)-2)):
        qc.rz(-pi/2,i+1)
        qc.cx(i+1,i)
        qc.rz(pi/2-phi,i)
        qc.ry(phi-pi/2,i+1)
        qc.cx(i,i+1)
        qc.ry(pi/2-phi,i+1)
        qc.cx(i+1,i)
        qc.rz(pi/2,i)

qc.barrier()
# Implementation of the odd interactions
for i in range(num_q-1):
    if ((i%2)==1 and (i <= (num_q)-2)):
        qc.rz(-pi/2,i+1)
        qc.cx(i+1,i)
        qc.rz(pi/2-phi,i)
        qc.ry(phi-pi/2,i+1)
        qc.cx(i,i+1)
        qc.ry(pi/2-phi,i+1)
        qc.cx(i+1,i)
        qc.rz(pi/2,i)
    
qc.barrier()

# Here we draw the quantum circuit
qc.draw(output='mpl')

