# How to properly make phase estimation with qiskit's modules

I have been making several experiments with qiskits' Quantum Phase Estimation modules, such as with QPE and EigsQPE. For example, the following code tries to estimate the phase of the second eigenvector of the unitary matrix variable.

# building inverse quantum fourier transform
iqft = StandardIQFTS(3)
phase = 1/8
#defining unitary matrix and initial state
matrix = np.array([[1,0],[0,np.exp(2*1j*np.pi*phase)]])
vector = np.array([0,1])
init_state = Custom(1,state_vector=vector)

# Defining Quantum Phase Estimation object
qpe = QPE(MatrixOperator(matrix=matrix),
state_in=init_state,
iqft=iqft,
num_time_slices=1,
num_ancillae=3,
expansion_mode="trotter",
expansion_order=1,
shallow_circuit_concat=False
)
qpe_circ = qpe.construct_circuit(True)
#eigs_circ.measure([0,1],[0,1])
qpe_circ.draw(output="mpl")


Below is a vanilla code I am using to check the answers for a simple Quantum Phase Estimation Problem.

# Inverse Quantum Fourier Transform
def qft_dagger(circ, n):
"""n-qubit QFTdagger the first n qubits in circ"""
# Don't forget the Swaps!
for qubit in range(int(n/2)):
circ.swap(qubit, n-qubit-1)
for j in range(n,0,-1):
k = n - j
for m in range(k):
circ.cu1(-np.pi/float(2**(k-m)), n-m-1, n-k-1)
circ.h(n-k-1)
# Create and set up circuit
qpe = QuantumCircuit(4, 3)
# Apply H-Gates to counting qubits:
for qubit in range(3):
qpe.h(qubit)
# Prepare our eigenstate |psi>:
qpe.initialize([0,1],[3])
# Do the controlled-U operations:
phase = 1/8
angle = 2*np.pi*phase
repetitions = 2**2
for counting_qubit in range(3):
for i in range(repetitions):
qpe.cu1(angle, counting_qubit, 3);
repetitions //= 2
# Do the inverse QFT:
qft_dagger(qpe, 3)
# Measure
qpe.measure(0,2)
qpe.measure(1,1)
qpe.measure(2,0)

qpe.draw(output='mpl')



The second code snippet works perfectly, while the first one using the QPE` function gives wrong answers. What choice of parameters would make the first code work?