# Importing standard Qiskit libraries
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.visualization import *
from qiskit.quantum_info import state_fidelity
# Numpy for numeric functions
import numpy as np
# Magic function to render plots in the notebook after the cell executing the plot command
%matplotlib inline

def run_on_statevector_simulator(quantum_circuit, decimals=6):
    """Takes a circuit, and runs it on the state vector simulator backend."""
    statevector_simulator = Aer.get_backend('statevector_simulator')
    job = execute(quantum_circuit, backend=statevector_simulator)
    result = job.result()    
    statevector = result.get_statevector(quantum_circuit, decimals=decimals)
    return statevector

# Generate a quantum circuit for two qubits

# Add the gates which generate |psi_0>

# Draw the quantum circuit


# Run it on the state vector simulator


# Visualize the resulting state vector


# Add a CNOT gate to the circuit

# Draw the circuit


# Run it on the state vector simulator


# Visualize the resulting state vector


# Generate a quantum circuit qc2 for two qubits
qc2 = QuantumCircuit(2)
# Add the gates which generate |psi_0>

# Draw the quantum circuit


# Run it on the state vector simulator for various angles of Rx
# Number of steps
nsteps = 10
for i in range(nsteps):
    # We copy the quantum circuit qc2 into a new circuit qc3
    qc3 = QuantumCircuit(2)
    qc3.compose(qc2, inplace=True)
    # Add the controllec Rx gates between qubits 0 and 1 for various angles
    # Hint set: the angle to i*4*np.pi/nsteps
    
    # Run the resulting circuit on the state vector simulator
    vec = run_on_statevector_simulator(qc3)
    # Visualize the state vector
    