Skip to content

Operators' Estimation

The operators' estimation module computes estimated expectation values of quantum operators \(O_i\) given a quantum state \(|\psi\rangle\):

\[ E_i = \langle\psi | O_i | \psi\rangle \]

The quantum operators \(O_i\) need not necessarily be Hermitian. Therefore, the estimates \(E_i\), that are the main estimation result, are generally complex numbers. The quantum state is represented by a quantum circuit.

Executing the Estimation task


Each of the operators is a sum of Pauli operators product:

\[ O_i = \sum_{j=1}^{n_i} \alpha_{i,j} P_1^{i,j} \otimes \cdots \otimes P_m^{i,j} \]
  • \(O_i\) is the i-th operator in the operators' list. Every parameter with \(i\) is related to this operator.
  • \(n_i\) is the number of distinct terms/summands in \(O_i\).
  • \(\alpha_{i,j}\) is the complex coefficient of the j-th summand in \(O_i\).
  • \(P_k^{i,j}\) are the Pauli operators of the relevant summand. Each operator is one of the following four: \(I\), \(X\), \(Y\), \(Z\).
  • \(m\) are the number of qubits. This property is global and cannot differ from one operator to another.

For example, the code block below defines operators, which consists of two operators \(O_1\) and \(O_2\), on \(m=4\) qubits:

from classiq.applications.chemistry import PauliOperator, PauliOperators

operators = PauliOperators(
        PauliOperator(pauli_list=[("XXYZ", 0.3 - 0.2j), ("IYYY", 1.4j)]),
                ("ZIII", 3.2),
                ("IXYI", -0.1),
                ("IIXY", 0.1),
                ("YIIX", -0.1),
                ("XYII", 0.1),

The operators are:

\[ O_1 = (0.3 - 0.2i)XXYZ + 1.4i IYYY \]
\[ O_2 = 3.2ZIII - 0.1IXYI + 0.1IIXY - 0.1YIIX + 0.1XYII \]


The quantum state \(|\psi\rangle\) is represented by a quantum program, which is a quantum circuit.

The following snippet defines a quantum state on four qubits:

from classiq.execution import QuantumProgram

quantum_state = QuantumProgram(
  include "";
  qubit[4] q;
  bit[4] c;

  h q[0];
  h q[1];
  h q[2];
  h q[3];
  x q[0];
  z q[2];
  rz(pi/4) q[3];
  c = measure q;

The quantum state can be generated by Classiq's functions, see creating circuits.


The estimator supports only OpenQASM programs to describe the quantum state.

Estimation Problem

The above operators and state are combined to a united problem before the execution.

from classiq.execution import OperatorsEstimation

operators_estimation = OperatorsEstimation(

The operators and state must all have the same number of qubits.


from classiq import Executor

estimation_result = Executor().execute(operators_estimation)

The estimation result contains the following lists, each list has the length of the number of operators:

  • value: the estimate \(\langle\psi | O_i | \psi\rangle\).
  • variance: the variance of the estimate (when the estimate is calculated from many shots).
  • metadata: EstimationMetadata - contains the number of shots and more execution properties.