# randomly create a 2-dimensional quantum state
from random import randrange
def random_quantum_state():
    first_entry = randrange(101)
    first_entry = first_entry/100
    first_entry = first_entry**0.5 
    if randrange(2) == 0: 
        first_entry = -1 * first_entry
    second_entry = 1 - (first_entry**2)
    second_entry = second_entry**0.5
    if randrange(2) == 0: 
        second_entry = -1 * second_entry
    return [first_entry,second_entry]

# import the drawing methods
from matplotlib.pyplot import plot, figure

# draw a figure
figure(figsize=(6,6), dpi=60) 

# draw the origin
plot(0,0,'ro') 

for i in range(100):
    # create a random quantum state
    quantum_state = random_quantum_state(); 
    # draw a blue point for the random quantum state
    x = quantum_state[0];
    y = quantum_state[1];
    plot(x,y,'bo') 

# randomly create a 2-dimensional quantum state
from random import randrange
def random_quantum_state():
    first_entry = randrange(101)
    first_entry = first_entry/100
    first_entry = first_entry**0.5 
    if randrange(2) == 0: 
        first_entry = -1 * first_entry
    second_entry = 1 - (first_entry**2)
    second_entry = second_entry**0.5
    if randrange(2) == 0: 
        second_entry = -1 * second_entry
    return [first_entry,second_entry]

# import the drawing methods
from matplotlib.pyplot import plot, figure, arrow

%run qlatvia.py

# draw a figure
figure(figsize=(6,6), dpi=60) 

draw_axes();

# draw the origin
plot(0,0,'ro') 

for i in range(100):
    # create a random quantum state
    quantum_state = random_quantum_state(); 
    # draw a blue vector for the random quantum state
    x = quantum_state[0];
    y = quantum_state[1];
    # shorten the line length to 0.92
    #     line_length + head_length (0.08) should be 1
    x = 0.92 * x
    y = 0.92 * y
    arrow(0,0,x,y,head_width=0.04,head_length=0.08,color="blue")

# %%writefile FILENAME.py
# import the drawing methods
from matplotlib.pyplot import figure, arrow, text

def display_quantum_state(x,y,name):
    x1 = 0.92 * x
    y1 = 0.92 * y
    arrow(0,0,x1,y1,head_width=0.04,head_length=0.08,color="blue")
    x2 = 1.15 * x
    y2 = 1.15 * y
    text(x2,y2,name)

#
# test your function
#

# import the drawing methods
from matplotlib.pyplot import figure

figure(figsize=(6,6), dpi=80) # size of the figure

# include our predefined functions
%run qlatvia.py

# draw axes
draw_axes()

# draw the unit circle
draw_unit_circle()

for i in range(6):
    s = random_quantum_state()
    display_quantum_state(s[0],s[1],"v"+str(i))
    #draw_quantum_state(s[0],s[1],"v"+str(i))

