#this code block imports some basic libraries we will need
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import cmath as cm
import math
#remember, to execute this block you need to press SHIFT + ENTER

# Use this code block to write methods that construct operators
# as well as perform Inner and Outer products. You should make use
# of the Bra and Ket constructors
def Ket(a,b):
return np.array([[a],[b]])
def Bra(a,b=None):
if b==None:
return (a.conjugate()).transpose()
else:
return np.array([[a,b]])
def Operator():
return
def Inner(B,K): #make sure you know the dimenstions of what you are inputting
return
def Outer(K,B): #make sure you know the dimenstions of what you are inputting
return

# Use this code block to test your new methods inlcuding Bra, Ket
# Operator, Inner Products, Outer Products. Make sure to print
# the results in a format that is easy to understand.

# Use this code block to write your Prob() method

# Use this code block to perform the other requested calculations.

# This code block will install the IBM Qiskit package
!pip install Qiskit

from qiskit.visualization import plot_bloch_vector #you only need to perform this import once
plot_bloch_vector([0,1,0], title="New Bloch Sphere");

# This code block defines a method PlotKet() which takes a normalized ket as input
# then calculates the Pauli coefficients that are used to plot the ket on the
# Bloch Sphere
def PlotKet(K):
#define Pauli Matrices
sx=np.array([[0,1],[1,0]])
sy=np.array([[0,0+-1j],[0+1j,0]])
sz=np.array([[1,0],[0,-1]])
#get outer product of ket to make projection operator O
B=Bra(K)
O=Outer(K,B)
#calculate coefficients
B=np.trace(O.dot(sx)).real #notice we insuring these values are real
C=np.trace(O.dot(sy)).real
D=np.trace(O.dot(sz)).real
#now plot Bloch Sphere
plot_bloch_vector([B,C,D], title= 'State {}'.format(K));

K=GetRandom()
K=Normalize(K)
PlotKet(K)

# Use this code block to explore the behaivor of the Pauli Matrices
# as operators on kets