Mermin evaluation¶
This module is a SageMath module aimed at computing Mermin operators optimized to detect a specific quantum state.
-
mermin_eval.
M
(n, a, a_prime)[source]¶ - M_n is defined as such:
- M_n = (1/2)*(M_(n-1).tensor(a + a’) + M’_(n-1).tensor(a - a’))
Parameters: - n (int) – Iteration for the Mermin operator (determines its size).
- a,a_prime (matrix) – Size 2 hermitian operators, defining M as given above.
Returns: matrix – A size 2^n operator, following the definition given above.
-
mermin_eval.
M_all
(_n, _a, _a_prime)[source]¶ - M_n is defined as such:
- M_n = (1/2)*(M_(n-1).tensor(a_n + a_n’) + M’_(n-1).tensor(a-n - a-n’))
Parameters: Returns: matrix – A size 2^n operator, following the definition given above.
-
mermin_eval.
M_eval
(a, b, c, m, p, q, phi)[source]¶ This function evaluates <phi*|M_n|*phi> with (a,b,c,m,p,q) describing M_n, the Mermin operator.
M_n traditionally uses two families of operators, a_n and a’_n, in our case, a_n = a*X+b*Y+c*Z and a’_n = m*X+p*Y+q*Z.Parameters: - a,b,c,m,p,q (real) – Coefficients for the Mermin operator, used as described above.
- phi (vector[complex]) – Vector to be evaluated with M.
Returns: complex – <phi*|M_n|*phi>
-
mermin_eval.
M_eval_all
(_n, _a_coefs, _a_prime_coefs, _rho)[source]¶ This function evaluates tr(M_n * rho) with a and a’ describing Mn, the Mermin operator.
The coefficients must be given in the following shape: >>> [[a,b,c], [d,e,f], …] and will result in the following family of observables: >>> a[0] = a*X + b*Y + c*Z >>> a[1] = d*X + e*Y + f*Z >>> …
Parameters: Returns: complex
-
mermin_eval.
M_from_coef
(n, a, b, c, m, p, q)[source]¶ Returns the Mermin operator for a given size n and coefficients a through q.
M traditionally uses two families of operators, a_n and a’_n, in our case, a_n = a*X+b*Y+c*Z and a’_n = m*X+p*Y+q*Z.Parameters: - n (int) – Iteration for the Mermin operator (determines its size).
- a,b,c,m,p,q (real) – Coefficients for the Mermin operator, used as described above.
Returns: matrix – The Mermin operator M_n.
-
mermin_eval.
M_from_coef_all
(_n, _a_coefs, _a_prime_coefs)[source]¶ - Returns the Mermin operator for a given size n and coefficients of a
- and a’
The coefficients must be given in the following shape: >>> [[a,b,c], [d,e,f], …] and will result in the following family of observables: >>> a[0] = a*X + b*Y + c*Z >>> a[1] = d*X + e*Y + f*Z >>> …
Parameters: Returns: matrix – The Mermin operator M_n.
-
mermin_eval.
M_prime
(n, a, a_prime)[source]¶ - M’_n is defined as such:
- M’_n = (1/2)*(M’_(n-1).tensor(a + a’) + M_(n-1).tensor(a’ - a))
Parameters: - n (int) – Iteration for the Mermin operator (determines its size).
- a,a_prime (matrix) – Size 2 hermitian operators, defining M as given above.
Returns: matrix – A size 2^n operator, following the definition given above.
-
mermin_eval.
M_prime_all
(_n, _a, _a_prime)[source]¶ - M’_n is defined as such:
- M’_n = (1/2)*(M’_(n-1).tensor(a_n + a_n’) + M_(n-1).tensor(a_n’ - a_n))
Parameters: Returns: matrix – A size 2^n operator, following the definition given above.
-
mermin_eval.
coefficients_packing
(_a_a_prime_coefs)[source]¶ Packs a list of elements in two lists of lists of three elements
Example: >>> coefficients_packing([1,2,3,4,5,6,7,8,9,10,11,12]) ([[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]])
- This function is used to interface above …_all functions and the
- optimize function.
Parameters: _a_a_prime_coefs (list[any]) – List of elements. Returns: tuple[list[list[any]]] – Lists of lists of elements as described above.
-
mermin_eval.
coefficients_unpacking
(_a_coefs, _a_prime_coefs)[source]¶ Unpacks two lists of lists of three elements to one list of elements
Example: >>> coefficients_unpacking([[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]) [1,2,3,4,5,6,7,8,9,10,11,12]
- This function is used to interface above …_all functions and the
- optimize function.
Parameters: _a_coefs, _a_prime_coefs (tuple[list[list[any]]]) – Lists of lists of elements as described above. Returns: list[any] – List of elements.
-
mermin_eval.
mermin_coef_opti
(target_state, verbose=False)[source]¶ Returns the Mermin operator maximizing the measure for a given input.
Parameters: Returns: matrix, real – Coefficients of the optimal Mermin operator for target_state in th Grover algorithm and the value reached.
-
mermin_eval.
mermin_coef_opti_all
(phi, verbose=False)[source]¶ Returns the Mermin operator’ coefficients maximizing tr(M_n * rho) for a given input phi (where \(rho = |phi><phi|\) is the density matrix corresponding to the state phi).
Parameters: Returns: list[real], real – Coefficients of the optimal Mermin operator for target_state in th Grover algorithm and the value reached.
-
mermin_eval.
mermin_operator_opti
(target_state_vector, precomputed_filename=None, verbose=False)[source]¶ Computes the pseudo optimal operator used to perform the Mermin evaluation during Grover’s algorithm.
Parameters: - target_state_vector (vector[int]) – State searched by Grover’s algorithm (only single item searches are supported for now).
- precomputed_filename (str) – File where the precomputed coefficients for optimal Mermin operator are stored, if left empty, precomputation will not be used. If precomputation is used and the searched state is not in this database, once the optimization done, the result will be added to the file.
- verbose (bool) – If verbose then extra run information will be displayed in terminal.
Returns: matrix, real – The Mermin operator satisfying the required conditions and the value reached.