!pip install qiskit
!pip install ipywidgets
token='**********************'
from qiskit import QuantumCircuit, execute, Aer, IBMQ
IBMQ.save_account(token)
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
provider = IBMQ.load_account()
# Copy and paste the circut code from the IBM composer below
# Load IBM Q account and connect to quantum computer "armonk"
# you should check which computer is the least busy and change the backend
backend = provider.backends.ibmq_armonk
shots = 1024
results = execute(circuit, backend=backend, shots=shots).result()
answer = results.get_counts()
plot_histogram(answer)
Angles=[,]
Spin_Up=[,]
Spin_Down=[,]
# This code block will produce a scatter plot of your experimental data
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format='retina'
plt.scatter(Angles,Spin_Up,marker='o',label='Measured Spin Up')
plt.scatter(Angles,Spin_Down, marker='^',label='Measured Spin Down')
plt.xlabel('Rotation Angle')
plt.ylabel('Probability')
plt.xlim(0,pi)
plt.ylim(0,1)
plt.title('Stern-Gerlach Experimental Outcomes')
plt.legend();
# This code block will produce a plot that compares your experimental data to the theortical values
plt.scatter(Angles,Spin_Up,marker='o',label='Measured Spin Up')
plt.scatter(Angles,Spin_Down, marker='^',label='Measured Spin Down')
import numpy as np
t=np.linspace(0,pi,100)
tup=np.cos(t/2)**2
tdown=np.sin(t/2)**2
plt.plot(t,tup,color='b',label='Theoretical Spin Up')
plt.plot(t,tdown,color='orange',label='Theoretical Spin Down')
plt.xlabel('Rotation Angle')
plt.ylabel('Probability')
plt.xlim(0,pi)
plt.ylim(0,1)
plt.title('Stern-Gerlach Experimental Outcomes')
plt.legend();