apply_controlled_Q(fn, wires, target_wire, control_wire, work_wires)[source]

Provides the circuit to apply a controlled version of the \(\mathcal{Q}\) unitary defined in this paper.

The input fn should be the quantum circuit corresponding to the \(\mathcal{F}\) unitary in the paper above. This function transforms this circuit into a controlled version of the \(\mathcal{Q}\) unitary, which forms part of the quantum Monte Carlo algorithm. The \(\mathcal{Q}\) unitary encodes the target expectation value as a phase in one of its eigenvalues. This phase can be estimated using quantum phase estimation (see QuantumPhaseEstimation for more details).

  • fn (Callable) – a quantum function that applies quantum operations according to the \(\mathcal{F}\) unitary used as part of quantum Monte Carlo estimation

  • wires (Union[Wires or Sequence[int]]) – the wires acted upon by the fn circuit

  • target_wire (Union[Wires, int]) – The wire in which the expectation value is encoded. Must be contained within wires.

  • control_wire (Union[Wires, int]) – the control wire from the register of phase estimation qubits

  • work_wires (Union[Wires, Sequence[int], or int]) – additional work wires used when decomposing \(\mathcal{Q}\)


The input function transformed to the \(\mathcal{Q}\) unitary

Return type



ValueError – if target_wire is not in wires