mimiqcircuits.operations.expectationvalue

Expectation value operation.

Classes

ExpectationValue(op)

Operation to compute and store the expectation value of an Operator in a z-register.

class mimiqcircuits.operations.expectationvalue.ExpectationValue(op)[source]

Bases: Operation

Operation to compute and store the expectation value of an Operator in a z-register.

An expectation value for a pure state \(| \psi \rangle\) is defined as:

Expectation Value for Pure State

\[\langle O \rangle = \langle \psi | O | \psi \rangle\]

where \(O\) is an operator. With respect to a density matrix \(\rho\), it’s given by:

Expectation Value for Density Matrix

\[\langle O \rangle = \mathrm{Tr}(\rho O).\]

However, when using quantum trajectories to solve noisy circuits, the expectation value is computed with respect to the pure state of each trajectory.

The argument op can be any gate or non-unitary operator.

Note

ExpectationValue is currently restricted to one and two qubit operators.

See also

AbstractOperator, Gate

Examples

In push!, the first argument corresponds to the qubit, and the second to the z-register.

>>> from mimiqcircuits import *
>>> ExpectationValue(GateX())
⟨X⟩
>>> c = Circuit()
>>> c.push(ExpectationValue(GateX()), 1, 1)
2-qubit, 2-zvar circuit with 1 instruction:
└── ⟨X⟩ @ q[1], z[1]
>>> c.push(ExpectationValue(SigmaPlus()), 1, 2)
2-qubit, 3-zvar circuit with 2 instructions:
├── ⟨X⟩ @ q[1], z[1]
└── ⟨SigmaPlus(1)⟩ @ q[1], z[2]
__init__(op)[source]
opname()[source]
property qregsizes
property cregsizes
property zregsizes
inverse()[source]
power(_)[source]
static isunitary()[source]

Check if the class represents a unitary operator.

By default, this method returns False unless explicitly overridden in a subclass.

iswrapper()[source]
asciiwidth(qubits, bits=[], zvars=[])[source]

Calculate the width for ASCII drawing.

get_operation()[source]
getparams()[source]
evaluate(d)[source]