%run init.ipynb

4312/8192, 8155/8192

a,b,c,d = symbols('a b c d')
a, b, c, d

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, I

rho = a*X+b*Y+c*Z+d*I; rho

tr(X*rho), simplify(tr(Y*rho)), tr(Z*rho), tr(I*rho),

pp=4260/8192; pop=4470/8192; p0=8158/8192; pp, pop, p0

Xav = 2*pp-1; Yav = 2*pop-1; Zav = 2*p0-1; Xav, Yav, Zav

def rho_1qb_tomo(Xav,Yav,Zav):
    return (1/2)*(Xav*X+Yav*Y+Zav*Z+I)
rho = rho_1qb_tomo(Xav,Yav,Zav); rho, rho.eigenvects()

c00, a1, a2, a3, b1, b2, b3 = symbols('c_{00} a_1 a_2 a_3 b_1 b_2 b_3')
c11, c12, c13, c21,c22,c23,c31,c32,c33 = symbols('c_{11} c_{12} c_{13} c_{21} c_{22} c_{23} c_{31} c_{32} c_{33}')
c00, a1, a2, a3, b1, b2, b3, c11, c12, c13, c21,c22,c23,c31,c32,c33


rho = c00*tp(I,I) + a1*tp(X,I) + a2*tp(Y,I) + a3*tp(Z,I) + b1*tp(I,X) + b2*tp(I,Y) + b3*tp(I,Z) 
rho += c11*tp(X,X) + c12*tp(X,Y) + c13*tp(X,Z) + c21*tp(Y,X) + c22*tp(Y,Y) + c23*tp(Y,Z)
rho += c31*tp(Z,X) + c32*tp(Z,Y) + c33*tp(Z,Z)
rho

tr(rho), tr(rho*tp(X,I)), simplify(tr(rho*tp(Y,I))), simplify(tr(rho*tp(Z,I))), \
simplify(tr(rho*tp(I,X))), simplify(tr(rho*tp(I,Y))), simplify(tr(rho*tp(I,Z))), \
tr(rho*tp(X,X)), simplify(tr(rho*tp(X,Y))), simplify(tr(rho*tp(X,Z))), \
simplify(tr(rho*tp(Y,X))), simplify(tr(rho*tp(Y,Y))), simplify(tr(rho*tp(Y,Z))), \
tr(rho*tp(Z,X)), simplify(tr(rho*tp(Z,Y))), simplify(tr(rho*tp(Z,Z)))

n = 137; N = 4**n-1; N-10**82

p00 = 3906/8192; p01 = 257/8192; p10 = 253/8192; p11 = 3776/8192; p00,p01,p10,p11

