%run init.ipynb

X = Matrix([[0,1],[1,0]]); Y = Matrix([[0,-1j],[1j,0]]); Z = Matrix([[1,0],[0,-1]]); I = Matrix([[1,0],[0,1]])
x,y,z=symbols('x y z'); rho = (1/2)*(x*X+y*Y+z*Z+I); rho

rho.eigenvals()

from qiskit.visualization import plot_bloch_vector

plot_bloch_vector([[0.5,0.5,0.3]])

# Exemplo de representacao de vários estados na esfera de Bloch
points = []
r = 0.1; M = 3; dr = 1/M
for k in range(0, M):
    r += dr
    th = math.pi/2; ph = 0+k*0.01; N = 10; dph = 2*math.pi/N
    for j in range(0, N):
        ph += dph
        x = r*math.sin(th)*math.cos(ph); y = r*math.sin(th)*math.sin(ph); z = r*math.cos(th)
        points.append([x,y,z])
plot_bloch_vector(points)
#bb.savefig('blochb.pdf', format = 'png', dpi = 100)

trace(rho**2)

