def localPointsBeforeTreshold(N): def hypoTreshold(a0, a1, b0, b1): def value(a, b): return -np.sin(a) * np.sin(b) / (np.cos(a) * np.cos(b) - 1) return value(a0, b0), value(a0, b1), value(a1, b0), value(a1, b1) for i in range(N): if i % 100 == 0: print(f'{i+1}/{N}') a0 = np.random.rand() * np.pi a1 = np.random.rand() * np.pi b0 = np.random.rand() * np.pi b1 = np.random.rand() * np.pi P = T.find_P(np.pi / 2, a0, a1, b0, b1) if T.TLM(P): # treshold = tresholdTheta(a0,a1,b0,b1, 1e-5) tresholds = hypoTreshold(a0, a1, b0, b1) n = 100 # Theta = np.linspace(0, treshold,n) Theta = np.linspace(0, np.pi / 2, n) for theta in Theta: for tresh in tresholds: if np.abs(theta - tresh) < 0.03: print("facet") P = T.find_P(theta, a0, a1, b0, b1) nl = T.is_nonlocalPoint(P) print(nl) print("next")
def hypothesis2(N): tlm0flag0 = 0 tlm0flag1 = 0 tlm1flag0 = 0 tlm1flag1 = 0 for i in range(N): if i % 100 == 0: print(f'{i+1}/{N}') a0 = np.random.rand() * 2 * np.pi a1 = np.random.rand() * 2 * np.pi b0 = np.random.rand() * 2 * np.pi b1 = np.random.rand() * 2 * np.pi theta = np.pi / 2 P = T.find_P(theta, a0, a1, b0, b1) tlm = T.TLM(P) # print("TLM", tlm) flag = optimalTheta(a0, a1, b0, b1) # print(tlm, flag, "tutaj") if tlm: if flag: tlm1flag1 += 1 else: tlm1flag0 += 1 else: if flag: tlm0flag1 += 1 else: tlm0flag0 += 1 print(tlm1flag1, tlm1flag0, tlm0flag1, tlm0flag0)
def check(theta, a0, a1, b0, b1): P = T.find_P(theta, a0, a1, b0, b1) Qs = St.satoshiTestComment(P) tlm = T.TLM(T.find_P(np.pi / 2, a0, a1, b0, b1)) wholeSp, thetaNew = St.SPlusCondition(P) Qw = newTest(theta, a0, a1, b0, b1) # flag = optimalTheta(a0,a1,b0,b1) Qn = T.is_exposed(theta, a0, a1, b0, b1, 0.0001) print(theta, a0, a1, b0, b1) print(Qs, Qw, Qn, "extremal") print(tlm, wholeSp)
def newTest(theta, a0, a1, b0, b1): Pmax = T.find_P(np.pi / 2, a0, a1, b0, b1) tlm = T.TLM(Pmax) if tlm: P = T.find_P(theta, a0, a1, b0, b1) wholeSp, thetaNew = St.SPlusCondition(P) if np.abs(thetaNew - theta) > acc: print("something is wrong with theta") if wholeSp: return 1 return 0
def notUniquePointsInvestigating(N): for i in range(N): P = np.round(T.notUniquePoints(), 6) correct, realisation, wholeSp = T.twoQubitRepresentationSpecial(P) if correct: print(P, "point") theta, a0, a1, b0, b1 = realisation # print(correct, theta, a0/np.pi, a1/np.pi, b0/np.pi, b1/np.pi, wholeSp, np.sin(theta)**2, "tu") # print(P[0]/np.cos(theta), P[1]/np.cos(theta), P[2]/np.cos(theta), P[3]/np.cos(theta), "cosinusy prawdziwe") print(St.STLM(P, theta), "stlm") Ptlm = T.find_P(np.pi / 2, a0, a1, b0, b1) print(T.find_P(theta, a0, a1, b0, b1), "Punkt zwrotny") print(T.is_nonlocalPoint(P), "is nonlocal?") print(T.TLM(Ptlm), "Tlm") print(T.is_exposed(theta, a0, a1, b0, b1, 0.001), "exposed")
def tresholdTheta(a0, a1, b0, b1, acc): l = 0 r = np.pi / 2 P0 = T.find_P(r, a0, a1, b0, b1) if not T.TLM(P0): return np.pi / 2 while r - l > acc: theta = (r + l) / 2 Q = newTest(theta, a0, a1, b0, b1) # print(l,r,Q) if Q: r = theta else: l = theta return (r + l) / 2
def notUniquePoint(): # P = [0.4445537842667646, 0.24544802147218514, 0.734354006208671, 0.734354006208671, 0.542908951128687, 0.542908951128687, 0.3966948365612542, 0.3966948365612542] P5 = [0.024973, 0.058992, 0.5, 0.5, 0.07546, 0.07546, 0.092469, 0.092469] P4 = [ 0.25, 0.125, -0.262176, -0.0930301, -0.731555, -0.689269, -0.698783, 0.654382 ] P2 = [ 0.5, 0.5, -np.sqrt(2 / 5), 0, -np.sqrt(5 / 2) / 2, -np.sqrt(5 / 2) / 2 + 1 / np.sqrt(10), -np.sqrt(5 / 2) / 2, np.sqrt(5 / 2) / 2 - 1 / np.sqrt(10) ] P3 = [ 1 / 4, 1 / 2, -np.sqrt(7 / 3) / 3, 1 / np.sqrt(21), -37 / (12 * np.sqrt(21)), -37 / (12 * np.sqrt(21)) + 1 / 4 * (np.sqrt(7 / 3) / 3 + 1 / np.sqrt(21)), -np.sqrt(7 / 3) / 12 - 37 / (12 * np.sqrt(21)), -np.sqrt(7 / 3) / 12 + 43 / (12 * np.sqrt(21)) ] b = np.random.rand() a1 = np.random.rand() a0 = np.random.rand() b = 0.5 a0 = 0.25 a1 = 0.5 A0B0 = (a0 + a1 + a0 * b**2 - a1 * b**2) / (2 * b) A0B1 = A0B0 A1B0 = A0B0 - b * (a0 - a1) A1B1 = A0B0 - b * (a0 - a1) P = [a0, a1, b, b, A0B0, A0B1, A1B0, A1B1] # if A0B0 < 1: print(P, "punkt") correct, realisation, wholeSp = T.twoQubitRepresentation(P) theta, a0, a1, b0, b1 = realisation # print(correct, theta, a0/np.pi, a1/np.pi, b0/np.pi, b1/np.pi, wholeSp, np.sin(theta)**2, "tu") # print(P[0]/np.cos(theta), P[1]/np.cos(theta), P[2]/np.cos(theta), P[3]/np.cos(theta), "cosinusy prawdziwe") print(St.STLM(P, theta), "stlm") Ptlm = T.find_P(np.pi / 2, a0, a1, b0, b1) print(T.find_P(theta, a0, a1, b0, b1), "Punkt zwrotny") print(T.TLM(Ptlm), "Tlm") print(T.is_exposed(theta, a0, a1, b0, b1, 0.001), "exposed")
def tlmVSstlm(N): for i in range(N): if i % 100 == 0: print(f'{i+1}/{N}') a0 = np.random.rand() * 2 * np.pi a1 = np.random.rand() * 2 * np.pi b0 = np.random.rand() * 2 * np.pi b1 = np.random.rand() * 2 * np.pi theta = np.random.rand() * np.pi / 2 P1 = T.find_P(np.pi / 2, a0, a1, b0, b1) P2 = T.find_P(theta, a0, a1, b0, b1) tlm = T.TLM(P1) stlm = St.STLM(P2, theta) wholeSp, theta = St.SPlusCondition(P2) # print(tlm, stlm) if stlm and (not tlm): print(tlm, stlm) if stlm and (not tlm) and wholeSp: print(tlm, stlm, wholeSp) print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
def functionalBehaviour(N): for i in range(N): print(f'{i+1}/{N}') a0 = np.random.rand() * 2 * np.pi a1 = np.random.rand() * 2 * np.pi b0 = np.random.rand() * 2 * np.pi b1 = np.random.rand() * 2 * np.pi F1 = [] Tet = [] MAXI = [] tlm = T.TLM(T.find_P(np.pi / 2, a0, a1, b0, b1)) print(tlm) if tlm: thetag = T.getThetaFromSinSquared( T.hypoTreshold(a0, a1, b0, b1)**2) n = 500 Theta = np.linspace(thetag, np.pi / 2, n) for theta in Theta: # a0 = 3/4*np.pi # a1 = np.pi/4 # b0 = np.pi/2 # b1 = np.pi P = T.find_P(theta, a0, a1, b0, b1) wholeSp, thetaNew = St.SPlusCondition(P) # if wholeSp: # f1,m1 = T.Best_func(theta, a0, a1, b0, b1) f2, m2 = T.Best_func_restricted(theta, a0, a1, b0, b1) # print(m1-m2,"hmm") # print(f1) # print(f2) MAXI.append(m2) Tet.append(theta) F1.append(f2) # plt.plot(Tet,F1) plt.plot(Tet, MAXI) plt.show()
def nonnegativitySingularity(N): for i in range(1): a0 = 0 a1 = np.random.rand() * 2 * np.pi b0 = 0 b1 = np.random.rand() * 2 * np.pi P = T.find_P(np.pi / 2, a0, a1, b0, b1) # print(P) tlm = T.TLM(P) # Sp, Sm = St.SPlusTemp(P) # print(Sp) # print(Sm) # theta = np.random.rand()*np.pi/2 # thetaB = np.arcsin(T.hypoTreshold(a0,a1,b0,b1)) # print(thetaB) thetaGr = np.arcsin(T.hypoTresholdImproved(a0, a1, b0, b1)) print(thetaGr) Theta = np.linspace(0, np.pi / 2, N) for theta in Theta: # print(theta) # if i%100 == 0: # print(i) P = T.find_P(theta, a0, a1, b0, b1) stlm = St.STLM(P, theta) c1, thetan = St.SPlusCondition(P) if theta >= thetaGr: c2 = 1 else: c2 = 0 # sat = St.satoshiTest(P) # ex = T.is_exposed(theta,a0,a1,b0,b1, 0.001) if c1 and (not stlm): stlm2 = St.STLMComment(P, theta) print(tlm, stlm, c1, c2)
def plotExposed(D): acc = 1e-4 x0 = 0 x_end = np.pi / 2 y0 = 0 y_end = 1 Y = np.linspace(y0, y_end, D) X = np.linspace(x0, x_end, D) Map = np.zeros((D, D)) for y, CosA in enumerate(Y): for x, theta in enumerate(X): a0 = 0 b0 = 0 a1 = np.arccos(CosA) b1 = -np.arccos(CosA) + 2 * np.pi P = T.find_P(theta, a0, a1, b0, b1) P2 = symmetricPoint2(theta, CosA) # print(np.round(P-P2,7)) # exp1 = T.is_exposed(theta, a0, a1, b0, b1, acc) exp2 = T.is_exposed_hypo(theta, a0, a1, b0, b1) exp3 = St.satoshiTest(P) nonloc = T.is_nonlocalPoint(P) print(exp2) stlm = St.STLM(P, theta) Ptlm = T.find_P(np.pi / 2, a0, a1, b0, b1) tlm = T.TLM(Ptlm) print(stlm, tlm) Map[x][D - y - 1] = exp2 plt.imshow(Map.T, extent=[x0, x_end, y0, y_end]) plt.colorbar() plt.xlabel("theta") plt.ylabel("cos(a)") plt.savefig("symmetric.png") plt.show()