print("== parameter ==") gamma = 0.5 H = make_hamiltonian() print("gamma =", gamma) print("== initial density operator ==") u_1 = math.sqrt(1 / 3) u_2 = math.sqrt(1 / 3) u_3 = math.sqrt(1 / 3) D = make_densop_matrix(u_1, u_2, u_3) de = DensOp(matrix=D) de.show() print("square trace =", de.sqtrace()) print("(u_1,u_2,u_3) = ({0:.3f},{1:.3f},{2:.3f})".format(u_1, u_2, u_3)) print("expect value of energy =", de.expect(matrix=H)) [M_0, M_1] = make_kraus(gamma=gamma) print("== finail density operator ==") de.instrument(kraus=[M_0, M_1]) de.show() print("square trace =", de.sqtrace()) (u_1, u_2, u_3) = get_coordinate(densop=de) print("(u_1,u_2,u_3) = ({0:.3f},{1:.3f},{2:.3f})".format(u_1, u_2, u_3)) print("expect value of energy =", de.expect(matrix=H))
from qlazypy import QState, DensOp qs_pure = QState(1).h(0) # (|0> + |1>) / sqrt(2.0) de_pure = DensOp(qstate=[qs_pure], prob=[1.0]) qs_pure_1 = QState(1) # |0> qs_pure_2 = QState(1).x(0) # |1> de_mixed = DensOp(qstate=[qs_pure_1, qs_pure_2], prob=[0.5, 0.5]) print("== pure state ==") de_pure.show() print("* trace =", de_pure.trace()) print("* square trace =", de_pure.sqtrace()) print("") print("== mixed state ==") de_mixed.show() print("* trace =", de_mixed.trace()) print("* square trace =", de_mixed.sqtrace()) qs_pure.free() qs_pure_1.free() qs_pure_2.free() de_pure.free() de_mixed.free()