I'm trying to implement Quantum Phase Estimation from qiskit textbook.
Below is the implementation circuit taken from the above-mentioned site:
The output at position 2 will be as follows:
$$|\psi _2⟩ = \frac{1}{2^{\frac{n}{2}}} \sum_{k=0}^{2^{n}-1} e^{2\pi i k} |k⟩ ⊗ |\psi⟩ $$
and after applying inverse QFT, the state becomes:
$$ | \psi _3⟩ = \frac{1}{2^{n}} \sum_{x=0}^{2^{n}-1} \sum_{k=0}^{2^{n}-1} e^{- \frac{2 \pi i k}{2^{n}}(x-2^n \theta)} |x⟩ ⊗| \psi⟩ $$
However, the next step claims that the above expression peaks near $ x = 2^n \theta $ which is my point of doubt, why is this the case? Wouldn't the maximum amplitude be when $ x = 0 $ based on simple calculus?