Skip to main contentIBM Quantum Documentation

unitary_overlap

class qiskit.circuit.library.unitary_overlap(unitary1, unitary2, prefix1='p1', prefix2='p2', insert_barrier=False)

GitHub

Bases:

Circuit that returns the overlap between two unitaries U2U1U_2^{\dag} U_1.

The input quantum circuits must represent unitary operations, since they must be invertible. If the inputs will have parameters, they are replaced by ParameterVectors with names “p1” (for circuit unitary1) and “p2” (for circuit unitary_2) in the output circuit.

This circuit is usually employed in computing the fidelity:

0U2U102\left|\langle 0| U_2^{\dag} U_1|0\rangle\right|^{2}

by computing the probability of being in the all-zeros bit-string, or equivalently, the expectation value of projector 00|0\rangle\langle 0|.

Reference Circuit:

import numpy as np
from qiskit.circuit.library import EfficientSU2, unitary_overlap
 
# get two circuit to prepare states of which we compute the overlap
circuit = EfficientSU2(2, reps=1)
unitary1 = circuit.assign_parameters(np.random.random(circuit.num_parameters))
unitary2 = circuit.assign_parameters(np.random.random(circuit.num_parameters))
 
# create the overlap circuit
overlap = unitary_overlap(unitary1, unitary2)
overlap.draw('mpl')
../_images/qiskit-circuit-library-unitary_overlap-1.png

Parameters

  • unitary1 (QuantumCircuit) – Unitary acting on the ket vector.
  • unitary2 (QuantumCircuit) – Unitary whose inverse operates on the bra vector.
  • prefix1 (str) – The name of the parameter vector associated to unitary1, if it is parameterized. Defaults to "p1".
  • prefix2 (str) – The name of the parameter vector associated to unitary2, if it is parameterized. Defaults to "p2".
  • insert_barrier (bool) – Whether to insert a barrier between the two unitaries.

Raises

  • CircuitError – Number of qubits in unitary1 and unitary2 does not match.
  • CircuitError – Inputs contain measurements and/or resets.

Return type

QuantumCircuit

Was this page helpful?
Report a bug or request content on GitHub.