MU Evaluation¶
- mu.a_matrix(n, t)[source]¶
Computes the matrix “a” of the Mermin polynomial based on three Pauli’s matrices.
- Example :
>>> a_matrix(3, [[-0.7,0.2,-0.7],[-0.36,0.5,0.7],[0.5,-0.8,0.4],[-0.5,-0.5,0.7], [0.9,-0.1,0.4],[0.4,0.7,0.5]]) [[ 0.43+0.j 0.9 +0.08j] [ 0.9 -0.08j -0.43+0.j ]]
- Parameters:
n (int) – The number of qubits.
- Parameter:
list(int) t : A list of 2 * n lists containing three (03) floats.
- Returns:
np.array(complex) – The matrix a of dimension 2*2.
- mu.a_prime_matrix(n, t)[source]¶
Computes the matrix “a’” of the Mermin polynomial ased on three Pauli’s matrices.
Example : >>> a_prime_matrix(3, [[-0.7,0.2,-0.7],[-0.4,0.5,0.7],[0.5,-0.8,0.4],[-0.5,-0.5,0.7],[0.9,-0.1,0.4],[0.4,0.7,0.5]])
- [[ 0.48+0.j 0.43-0.76j]
[ 0.43+0.76j -0.48+0.j ]]
- Parameters:
n (int) – The number of qubits.
- Parameter:
list(int) t : A list of 2 * n lists containing three (03) floats.
- Returns:
np.array(complex) – The matrix a’ of dimension 2*2.
- mu.first_coefficients_generation(n)[source]¶
Generates the very first coefficients for the calculation of MU by random walk algorithm.
- Example :
>>> first_coefficients_generation(3) [[-0.71636549 0.16623039 -0.67763407] [-0.36958952 0.54390424 0.75337359] [ 0.48738401 -0.78929548 0.37345613] [-0.51019129 -0.53759251 0.6713413 ] [ 0.89590429 -0.08368889 0.43629311] [ 0.42877383 0.76027758 0.48798669]]
- Parameters:
n (int) – The number of qubits.
- Returns:
np.array(list(complex)) – A table of 2 * n lists containing three (03) coefficients each.
- mu.mermin(n, t)[source]¶
Calculates the Mermin polynomial “mn” by recurrence.
- Example :
>>> mermin(2, [[0.62, -0.035, -0.78],[-0.22, 0.12, -0.97],[0.45, 0.68, -0.57],[0.2, 0.16, -0.97]]) [[ 0.4066 +0.j -0.37475+0.5798j -0.5214 -0.05095j 0.1575 -0.206825j] [-0.37475-0.5798j -0.4066 +0.j 0.1905 +0.199575j 0.5214 +0.05095j] [-0.5214 +0.05095j 0.1905 -0.199575j -0.4066 +0.j 0.37475-0.5798j] [ 0.1575 +0.206825j 0.5214 -0.05095j 0.37475+0.5798j 0.4066 +0.j]]
- Parameters:
n (int) – The number of qubits.
- Parameter:
list(int) t : A list of 2 * n lists containing three (03) floats.
- Returns:
np.array(complex) – The polynomial “mn” of dimension 2^n * 2^n.
- mu.mermin_prime(n, t)[source]¶
Calculates the Mermin polynomial “mn’” by recurrence from matrices “a” and “a’”
- Example :
>>> mermin_prime(2, [[0.62, -0.035, -0.78],[-0.22, 0.12, -0.97],[0.45, 0.68, -0.57],[0.2, 0.16, -0.97]]) [[ 0.9029+0.j -0.21775+0.2046j 0.0454+0.0854j -0.2085+0.210225j] [-0.21775-0.2046j -0.9029+0.j -0.0895-0.296975j -0.0454-0.0854j] [ 0.0454-0.0854j -0.0895+0.296975j -0.9029+0.j 0.21775-0.2046j] [-0.2085-0.210225j -0.0454+0.0854j 0.21775+0.2046j 0.9029+0.j]]
- Parameters:
n (int) – The number of qubits.
- Parameter:
list(int) t : A list of 2 * n lists containing three (03) floats.
- Returns:
np.array(complex) – The polynomial “mn’” of dimension 2^n * 2^n.
- mu.mu_calculation(mn, vector)[source]¶
Calculates “MU”, the result of the calculation of the vector with the mermin polynomial.
- Parameters:
mn (np.array(complex)) – The Mermin polynomial “mn”.
vector (list(int)) – The state vector.
- Returns:
float – The value of the calculation.
- mu.new_coefficients_generation(n, old_array, step)[source]¶
Generates randomly new parameters for MU maximization by random walk algorithm.
- Parameters:
n (int) – The number of qubits
old_array (np.array(list(float))) – The table of the coefficients that didn’t maximize Mu
step (float) – The value of the step (used in the random walk algorithm)
- Returns:
np.array(list(complex)) – Table of new coefficients
- mu.xbest_calculation(n, step, step_min, c_max, vector)[source]¶
- Maximizes Mu. The algorithm used here is called the Random walk method.
The principle is simple. We randomly generate first parameters which are used to calculate Mu. The first value of Mu is called Mu0. Then, we calculate new parameters based on the previous ones and a variable called the descent step. With the new parameters, we calculate a new value of Mu. If this value is better than the previous one, we keep it and continue the researches until a counter is at its maximum value. The goal here is to take a big circle of research scope and to reduce it (by decreasing the decent step) more and more until the maximum value of Mu is found.
- Parameters:
n (int) – The number of qubits.
step (int) – The initial value of the descent step.
step_min (float) – The minimum value of the descent step (which is the length of the radius).
c_max (int) – The maximum value of the counter.
vector (list(int)) – The vector for the calculation of Mu.
- Returns:
float – The value that is, expectedly, the optimal maximal value of Mu.