qrisp.app_sb_phase_polynomial#

app_sb_phase_polynomial(*args, permeability='args', is_qfree=True, verify=False, **kwargs)#

Applies a phase function specified by a semi-Boolean polynomial acting on a list of QuantumVariables. That is, this method implements the transformation

\[\ket{y_1}\dotsb\ket{y_n}\rightarrow e^{itP(y_1,\dotsc,y_n)}\ket{y_1}\dotsb\ket{y_n}\]

where \(\ket{y_1},\dotsc,\ket{y_n}\) are QuantumVariables and \(P(y_1,\dotsc,y_n)=P(y_{1,1},\dotsc,y_{1,m_1},\dotsc,y_{n,1}\dotsc,y_{n,m_n})\) is a semi-Boolean polynomial in variables \(y_{1,1},\dotsc,y_{1,m_1},\dotsc,y_{n,1}\dotsc,y_{n,m_n}\). Here, \(m_i\) is the size of the \(i\) th variable.

Parameters:
qv_listlist[QuantumVariable] or QuantumArray

The list of QuantumVariables to evaluate the semi-Boolean polynomial on.

polySymPy expression

The semi-Boolean polynomial to evaluate.

symbol_listlist, optional

An ordered list of SymPy symbols associated to the qubits of the QuantumVariables of qv_list. For each QuantumVariable in qv_list a number of symbols according to its size is required. By default, the symbols of the polynomial will be ordered alphabetically and then matched to the order in qv_list.

tFloat or SymPy expression, optional

The argument t in the expression \(\exp(itP)\). The default is 1.

Raises:
Exception

Provided QuantumVariable list does not include the appropriate amount of elements to evaluate the given polynomial.

Examples

We apply the phase function specified by the polynomial \(P(x,y,z) = \pi xyz\) on a QuantumVariable:

import sympy as sp
import numpy as np
from qrisp import QuantumVariable, app_sb_phase_polynomial

x, y, z = sp.symbols('x y z')
P = np.pi*x*y*z

qv = QuantumVariable(3)
qv.init_state({'000': 0.5, '111': 0.5})

app_sb_phase_polynomial([qv], P)

We print the statevector:

>>> print(qv.qs.statevector())
sqrt(2)*(|000> - |111>)/2