I'm trying to implement a circuit for Quantum Amplitude Estimation in Qiskit using elementary gates.
I have created the circuit that represent my algorithm $A$ but now from the theory I know that I have to create the Q-operator defined as: $Q = A S_0 A^{-1} S_{\psi_{0}}$ , where $S_0$ and $S_{\psi_{0}}$ are two reflections.
How can I implement these two reflections in the circuit using Qiskit gates?
UPDATE
I built a quantum circuit for reproducing an algorithm $A$ for computing expected value of a random variable, given by:
- Load a random variable X as a quantum state
$$ L|0\rangle_n = |\psi\rangle_n = \sum_{i=0}^{2^n - 1}\sqrt{p_i} |i\rangle_n \ \ \ such \ that \ \sum_{i=0}^{2^n - 1}p_i = 1 $$
- Create an operator for the encoding
$$ F|i\rangle_n |0\rangle = \sqrt{1 - f(i)} |i\rangle_n |0\rangle + \sqrt{f(i)} |i\rangle_n |1\rangle $$
So my algorithm $A$ is given by the final state:
$$
F (L|0\rangle_n)|0\rangle = F|\psi\rangle_n|0\rangle = \sum_{i=0}^{2^n-1} \sqrt{1 - f(i)} \sqrt{p_i} |i\rangle_n |0\rangle + \sum_{i=0}^{2^n-1} \sqrt{f(i)} \sqrt{p_i} |i\rangle_n |1\rangle
$$
I used 3 qubits for loading distribution and one ancilla qubit; so my Qiskit circuit is the following
From this I would create $Q$ operator for Amplitude Estimation. How can I procede?