# Quantum Fourier Transformation and Phase Estimation

Let's use Yao first

`using Yao`

## Quantum Fourier Transformation

The Quantum Fourier Transformation (QFT) circuit is to repeat two kinds of blocks repeatly:

The basic building block control phase shift gate is defined as

\[R(k)=\begin{bmatrix} 1 & 0\\ 0 & \exp\left(\frac{2\pi i}{2^k}\right) \end{bmatrix}\]

Let's define block `A`

and block `B`

, block `A`

is actually a control block.

`A(i, j) = control(i, j=>shift(2π/(1<<(i-j+1))))`

`A (generic function with 1 method)`

Once you construct the blockl you can inspect its matrix using `mat`

function. Let's construct the circuit in dash box A, and see the matrix of $R_4$ gate.

`R4 = A(4, 1)`

`(n -> control(n, 4, 1 => shift(0.39269908169872414)))`

If you have read about preparing GHZ state, you probably know that in Yao, we could just leave the number of qubits, and it will be evaluated when possible.

`R4(5)`

```
nqubits: 5
control(4)
└─ (1,) shift(0.39269908169872414)
```

its matrix will be

`mat(R4(5))`

```
32×32 LinearAlgebra.Diagonal{ComplexF64, Vector{ComplexF64}}:
1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1.0+0.0im ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 0.92388+0.382683im
```

Then we repeat this control block over and over on different qubits, and put a Hadamard gate to `i`

th qubit to construct `i`

-th `B`

block.

`B(n, k) = chain(n, j==k ? put(k=>H) : A(j, k) for j in k:n)`

`B (generic function with 1 method)`

We need to input the total number of qubits `n`

here because we have to iterate through from `k`

-th location to the last.

Now, let's construct the circuit by chaining all the `B`

blocks together

```
qft(n) = chain(B(n, k) for k in 1:n)
qft(4)
```

```
nqubits: 4
chain
├─ chain
│ ├─ put on (1)
│ │ └─ H
│ ├─ control(2)
│ │ └─ (1,) shift(1.5707963267948966)
│ ├─ control(3)
│ │ └─ (1,) shift(0.7853981633974483)
│ └─ control(4)
│ └─ (1,) shift(0.39269908169872414)
├─ chain
│ ├─ put on (2)
│ │ └─ H
│ ├─ control(3)
│ │ └─ (2,) shift(1.5707963267948966)
│ └─ control(4)
│ └─ (2,) shift(0.7853981633974483)
├─ chain
│ ├─ put on (3)
│ │ └─ H
│ └─ control(4)
│ └─ (3,) shift(1.5707963267948966)
└─ chain
└─ put on (4)
└─ H
```

## Wrap QFT to an external block

In most cases, `function`

s are enough to wrap quantum circuits, like `A`

and `B`

we defined above, but sometimes, we need to dispatch specialized methods on certain kinds of quantum circuit, or we want to define an external block to export, thus, it's useful to be able to wrap circuit to custom blocks.

First, we define a new type as subtype of `PrimitiveBlock`

since we are not going to use the subblocks of `QFT`

, if you need to use its subblocks, it'd be better to define it under `CompositeBlock`

.

```
struct QFT{N} <: PrimitiveBlock{N} end
QFT(n::Int) = QFT{n}()
```

`Main.##276.QFT`

Now, let's define its circuit

`circuit(::QFT{N}) where N = qft(N)`

`circuit (generic function with 1 method)`

And forward `mat`

to its circuit's matrix

`YaoBlocks.mat(::Type{T}, x::QFT) where T = mat(T, circuit(x))`

You may notice, it is a little ugly to print `QFT`

at the moment, this is because we print the type summary by default, you can define your own printing by overloading `print_block`

`YaoBlocks.print_block(io::IO, x::QFT{N}) where N = print(io, "QFT($N)")`

Since it is possible to use FFT to simulate the results of QFT (like cheating), we could define our custom `apply!`

method:

```
using FFTW, LinearAlgebra
function YaoBlocks.apply!(r::ArrayReg, x::QFT)
α = sqrt(length(statevec(r)))
invorder!(r)
lmul!(α, ifft!(statevec(r)))
return r
end
```

Now let's check if our `apply!`

method is correct:

```
r = rand_state(5)
r1 = r |> copy |> QFT(5)
r2 = r |> copy |> circuit(QFT(5))
r1 ≈ r2
```

`true`

We can get iQFT (inverse QFT) directly by calling `adjoint`

`QFT(5)'`

` [†]QFT(5)`

QFT and iQFT are different from FFT and IFFT in three ways,

- they are different by a factor of $\sqrt{2^n}$ with $n$ the number of qubits.
- the bit numbering will exchange after applying QFT or iQFT.
- due to the convention, QFT is more related to IFFT rather than FFT.

## Phase Estimation

Since we have QFT and iQFT blocks we can then use them to realize phase estimation circuit, what we want to realize is the following circuit:

`using Yao`

First we call Hadamard gates repeatly on first `n`

qubits.

`Hadamards(n) = repeat(H, 1:n)`

`Hadamards (generic function with 1 method)`

Then in dashed box `B`

, we have controlled unitaries:

`ControlU(n, m, U) = chain(n+m, control(k, n+1:n+m=>matblock(U^(2^(k-1)))) for k in 1:n)`

`ControlU (generic function with 1 method)`

each of them is a `U`

of power $2^(k-1)$.

Since we will only apply the qft and Hadamard on first `n`

qubits, we could use `Subroutine`

, which creates a context of a sub-scope of the qubits.

```
PE(n, m, U) =
chain(n+m, # total number of the qubits
subroutine(Hadamards(n), 1:n), # apply H in local scope
ControlU(n, m, U),
subroutine(QFT(n)', 1:n))
```

`PE (generic function with 1 method)`

we use the first `n`

qubits as the output space to store phase $ϕ$, and the other `m`

qubits as the input state which corresponds to an eigenvector of oracle matrix `U`

.

The concentrator here uses `focus!`

and `relax!`

to manage a local scope of quantum circuit, and only active the first `n`

qubits while applying the block inside the concentrator context, and the scope will be `relax!`

ed back, after the context. This is equivalent to manually `focus!`

then `relax!`

fullly activated

`r = rand_state(5)`

```
ArrayReg{1, ComplexF64, Array...}
active qubits: 5/5
```

first 3 qubits activated

`focus!(r, 1:3)`

```
ArrayReg{1, ComplexF64, Array...}
active qubits: 3/5
```

relax back to the original

`relax!(r, 1:3)`

```
ArrayReg{1, ComplexF64, Array...}
active qubits: 5/5
```

In this way, we will be able to apply small operator directly on the subset of the qubits.

Details about the algorithm can be found here: Quantum Phase Estimation Algorithm

Now let's check the results of our phase estimation.

First we need to set up a unitary with known phase, we set the phase to be 0.75, which is `0.75 * 2^3 == 6 == 0b110`

.

# using LinearAlgebra

```
N, M = 3, 5
P = eigen(rand_unitary(1<<M)).vectors
θ = Int(0b110) / 1<<N
phases = rand(1<<M)
phases[0b010+1] = θ
U = P * Diagonal(exp.(2π * im * phases)) * P'
```

```
32×32 Matrix{ComplexF64}:
-0.00684444+0.132532im -0.0600257-0.0213615im 0.0646327-0.137385im -0.0198606+0.034341im 0.0375189-0.160245im -0.116358-0.0669152im -0.0376042-0.252527im 0.255985-0.124631im -0.288782-0.159022im -0.116135-0.102959im -0.113774+0.19034im -0.217952-0.170227im 0.0502484-0.207222im 0.165646+0.0365452im -0.0279379-0.276573im -0.202591-0.0600873im 0.0695064-0.121207im 0.00877106+0.144709im -0.0225591+0.0398238im -0.0225734-0.00385587im -0.11166+0.102305im 0.109347-0.0715527im -0.18815-0.226955im -0.0381662+0.0266477im -0.00450923+0.0635274im -0.122583-0.0779381im -0.0472708-0.0534873im -0.0676551+0.0304775im 0.0989087-0.0784105im 0.00600368-0.0396667im -0.211639+0.0971571im 0.0983034+0.135364im
0.0836657-0.274103im -0.200187+0.126721im 0.0582521-0.0762007im -0.0263351+0.0279837im 0.131111+0.200417im 0.0794958-0.0739868im -0.0131076+0.0282892im 0.0456875-0.0981776im -0.0641389+0.126138im -0.157021-0.0827344im 0.0672108-0.0819505im 0.0606214-0.11497im -0.000475433-0.141567im -0.114725+0.0321432im 0.0529168-0.131006im 0.100667-0.102025im 0.206757-0.125975im 0.0411196-0.249361im -0.0571546+0.102081im -0.184515-0.0247621im 0.0991232-0.245737im 0.0734807+0.0571364im 0.077197-0.0193977im 0.000966595+0.0617681im 0.0726127+0.375311im -0.0456986+0.0577736im -0.157986-0.121829im 0.00177983+0.156203im 0.170275-0.0381603im 0.0744669-0.0779532im 0.243183+0.185058im -0.0276985-0.0544714im
0.151468-0.0369252im -0.0711099-0.163441im 0.0305907+0.0719839im 0.180513-0.0549365im -0.0969033+0.0571137im -0.115346-0.118877im -0.0364621-0.260126im 0.0227602+0.18147im -0.0269726+0.14164im 0.213859+0.0414385im -0.0759343+0.0769258im -0.055467+0.189806im 0.160419-0.0260461im 0.0099259+0.156558im 0.0878494-0.0542123im -0.0313216-0.0646091im -0.116534+0.0374747im 0.0464655-0.155746im -0.191821+0.204628im -0.145188+0.00512984im -0.238829-0.0824809im -0.0780599-0.0435415im -0.0856782+0.0120303im 0.226923+0.0554807im 0.131781+0.0683833im 0.165048-0.0767114im 0.20913+0.217169im -0.0715684-0.146093im -0.032159+0.00648416im 0.136727+0.0881867im 0.208325+0.0705899im 0.222993+0.0236222im
-0.151871+0.103761im -0.328995+0.121126im 0.172598+0.261111im -0.211222-0.098989im 0.0525847-0.119349im -0.0635754-0.00733153im 0.0628737+0.0208977im -0.0576188-0.0233886im -0.00889473+0.0625927im -0.128329+0.165563im -0.0339528-0.0677509im 0.149061+0.0709701im 0.151607-0.0745767im -0.088414-0.0493263im -0.0251705+0.0553727im -0.158172-0.0912688im 0.14656-0.0275013im -0.114339+0.158433im 0.10387+0.292636im 0.0752444-0.169199im -0.0654131-0.19262im -0.123098-0.0546266im -0.133678+0.088844im 0.0407664+0.0631938im -0.192542-0.0926508im -0.119405+0.115655im -0.0332567+0.0537507im 0.00576125-0.134713im -0.0847275-0.181936im 0.131575+0.213032im -0.0366958+0.0889742im -0.0559157-0.109104im
0.121009-0.0840061im -0.0473713-0.00295677im 0.0892104-0.00196892im -0.037403-0.0316992im -0.0140275-0.0451918im -0.115637-0.0158163im -0.133918-0.154011im 0.00556488-0.073072im -0.0063154+0.0208171im -0.192587-0.0810579im 0.214919+0.0759241im -0.0408043-0.0295429im 0.0195401+0.0362291im -0.114745+0.0575578im -0.10319-0.230483im 0.0782671-0.0497117im -0.0236094+0.182799im -4.61149e-5+0.187198im -0.0715681-0.0709782im 0.212481+0.0488125im -0.189464-0.184807im -0.224566+0.280503im -0.0445058-0.0854525im 0.15375-0.056456im -0.212911-0.0818986im 0.306082+0.141229im -0.0947036-0.0231322im 0.219643+0.112251im -0.070689+0.20758im -0.16339-0.0383486im 0.114168-0.0731053im -0.111478+0.092597im
0.191524-0.0412069im 0.0387405-0.00455705im 0.00310467-0.0835701im 0.145622+0.023193im 0.0661093-0.104489im -0.117172-0.0788801im 0.0894174+0.0240916im 0.0366082+0.0587676im -0.0158039-0.0822691im 0.149284+0.355255im 0.171569-0.220331im 0.123952-0.190512im 0.1926+0.142572im 0.044633-0.170008im -0.0513835-0.101435im -0.018711-0.0237922im -0.0879704+0.140738im -0.0904103+0.0782611im 0.233449+0.159994im -0.0187629-0.140828im 0.188654-0.0368664im -0.0973297+0.0280911im -0.160663-0.00752432im -0.00680889-0.0811645im 0.0513576-0.051164im -0.0727247-0.201255im 0.0475797+0.116331im 0.0107612+0.353232im 0.120141-0.0288341im -0.028168-0.14139im 0.0802233+0.0882736im 0.0733138+0.161903im
0.337553+0.175138im -0.228069+0.0668216im 0.108576+0.0231395im -0.104473-0.13472im 0.275022+0.217357im 0.112806-0.105748im -0.176309+0.0169055im 0.104891-0.0764573im 0.0374407+0.063107im 0.0418142+0.0640757im -0.170025-0.00271186im -0.254016+0.0316099im -0.0173102+0.112224im -0.025346-0.0666435im 0.061049-0.00683866im -0.0314366-0.0230626im -0.186549+0.160131im 0.0521951-0.014224im 0.0298507-0.0444131im -0.158218-0.0712666im -0.0541852-0.0337767im 0.107301+0.0538893im 0.0708108+0.236346im -0.0265781-0.0146706im -0.0194411-0.105161im 0.0166498+0.0312205im -0.178873+0.175249im -0.102424-0.0647269im 0.154345-0.148661im -0.164891-0.1318im -0.145954-0.204323im -0.102912+0.0521921im
-0.0398152-0.00585453im 0.232899+0.115645im 0.0810233-0.12239im 0.0915953-0.113593im 0.0312074+0.0832244im -0.0667307+0.0217031im -0.149443+0.119352im 0.0940945+0.0677777im -0.0718838+0.0410693im 0.00321541+0.14915im -0.00156824+0.0951488im 0.00967169-0.0724701im 0.14534+0.213488im 0.14884+0.229275im -0.107529-0.0306318im 0.102423-0.0948021im 0.0287056+0.0828503im -0.134436+0.0392326im -0.108789-0.0898777im -0.0362165-0.218714im -0.128152+0.156971im -0.0876816-0.233824im 0.192455+0.0351838im 0.0948611+0.14278im -0.239216-0.1015im -0.151086+0.10981im -0.0578932-0.251158im 0.0698621-0.1721im 0.120649-0.167039im -0.0296633-0.114076im 0.234004+0.15632im 0.0327879-0.0274977im
-0.0365712-0.187676im -0.0422708-0.24388im -0.00114098-0.161484im 0.0835251-0.027249im -0.113429-0.0755448im 0.0970366-0.0647922im -0.00835344-0.0543348im 0.0730832-0.0624172im 0.115451+0.250505im -0.0658587-0.0384415im 0.115921-0.189806im -0.0781191+0.0164479im 0.100784+0.0775206im -0.0935347+0.119062im -0.000133438-0.125292im 0.0301512-0.0093871im 0.250372-0.0694277im 0.0888158+0.20535im 0.18255-0.0505444im 0.0635966-0.127005im -0.0504526-0.0464495im -0.0135563-0.275044im 0.139066+0.046133im -0.216919-0.0513507im 0.1164-0.197079im 0.236376+0.110693im -0.103627+0.0772686im -0.2579-0.0435577im -0.0148219-0.012113im 0.174343-0.170151im -0.149696-0.0324402im 0.117948-0.0487627im
0.0525629+0.0404256im 0.071238-0.0758197im -0.00147825-0.204793im -0.136759-0.146454im -0.00780598-0.0404784im -0.217568-0.00781283im 0.00115212+0.167964im 0.114926+0.238496im 0.0695642+0.0225215im -0.177145-0.036507im -0.0897224-0.105699im -0.0692363+0.00115389im 0.136274+0.0181378im 0.0575641-0.131346im 0.0490112+0.102531im -0.106073+0.177523im 0.0609233-0.0403671im 0.00181317-0.267784im 0.122051-0.0545971im 0.323335+0.139875im -0.0522656-0.0388915im 0.140339+0.155909im -0.151418-0.0238186im -0.0434918+0.327972im -0.105306+0.00113909im 0.040195+0.270643im 0.0929961+0.0727593im -0.189834+0.0230847im 0.152835-0.00995194im 0.0111468-0.0247im 0.149724-0.0355059im 0.0932646+0.0692211im
0.0933529+0.12648im 0.186086+0.00545934im 0.0557867+0.132482im -0.0614956-0.0140949im -0.158853+0.0695591im -0.35232-0.0725102im -0.132987+0.0122157im 0.0639554-0.0361781im 0.0411811-0.268945im -0.0111227+0.0690567im -0.135472-0.15464im -0.0712655+6.83832e-5im 0.0772923-0.0972881im -0.315934+0.0293428im -0.0889711-0.039287im 0.0486037+0.0418934im 0.0109427-0.189571im -0.0371878-0.162885im -0.141538+0.256517im 0.0606064+0.0396263im 0.110389+0.082462im -0.074711+0.0391237im 0.226795+0.0881668im -0.127589-0.294026im 0.10415-0.0751929im 0.0832216+0.11058im -0.175563-0.123953im -0.0591453-0.0106027im -0.0707243-0.0476401im -0.1052+0.0161645im -0.0363999+0.0981139im 0.132206+0.0420487im
0.135152-0.147892im -0.152005-0.00662321im 0.110785-0.16758im -0.0549528+0.0978226im -0.0261878-0.0757374im 0.0635338-0.0132202im -0.107414-0.0794882im 0.080073+0.0604007im 0.236289-0.185712im -0.0321782+0.0028518im -0.0144037-0.153529im -0.0377862+0.104686im -0.00601416+0.185686im 0.147592-0.0639433im -0.0169531-0.0909041im -0.110284-0.00493333im -0.215455-0.132039im -0.0669227-0.114858im 0.131001-0.293386im -0.119033-0.0307798im 0.124801-0.105419im 0.000265931-0.0146765im -0.080927-0.136828im 0.113545-0.152268im -0.0327704-0.0912703im -0.0112848-0.00961224im -0.208196-0.224072im 0.0180468-0.141366im -0.0834947+0.00529693im 0.122185+0.407342im 0.0588214+0.0400516im 0.170454-0.0544695im
-0.122232+0.0465171im -0.105934+0.119168im 0.0653712-0.241311im -0.0679235-0.351541im -0.0887947-0.0916216im -0.0340139+0.148079im 0.0593521+0.202558im -0.144468+0.0545172im -0.0597988+0.0203938im -0.0205521-0.212505im -0.0282664-0.0738485im -0.132986-0.0682561im -0.2951+0.134848im -0.240715+0.0545515im 0.21979+0.0451802im -0.00566514-0.0891086im -0.0574883-0.0280933im -0.122667+0.11766im -0.188377-0.0102066im -0.163357-0.125555im 0.00730669+0.0811309im -0.128145-0.0303055im -0.105051-0.0473399im 0.0740548-0.202427im -0.0475041-0.0191976im 0.0236608+0.0192015im 0.0931278+0.108966im -0.117124+0.197269im 0.1282-0.0107871im 0.0355473+0.087854im 0.0584286+0.0335442im 0.174632+0.155874im
0.111723+0.0744848im 0.0663822+0.178256im -0.124271+0.00945653im -0.119754-0.189127im -0.0622127-0.0356061im -0.142147+0.213425im 0.0954565-0.114614im 0.0243046-0.194866im 0.134946+0.121629im 0.177743-0.149322im 0.0565683-0.216799im 0.0734857+0.0304555im 0.0279693+0.0908201im -0.0251247-0.190302im -0.0113218-0.0707506im -0.0115203-0.000813068im -0.201825+0.151741im 0.0124099+0.0244867im -0.0820103+0.056469im 0.00815573-0.15465im -0.151806+0.00101895im 0.164303+0.0493991im 0.0144054-0.342868im -0.154108+0.121459im 0.195285+0.0325556im 0.131698-0.0144142im 0.0149638-0.140745im -0.00755202-0.161217im 0.00866363-0.114103im 0.0712116-0.0503576im -0.0297967+0.24332im -0.24218-0.0666235im
0.206194+0.035685im -0.142281-0.254062im 0.0681794-0.245025im -0.0240287-0.0852933im -0.0732468-0.222036im -0.0074692-0.0822344im 0.124872+0.0203709im 0.0154736+0.014206im 0.00575142-0.0901407im -0.156581+0.052141im -0.0470142-0.126762im -0.158311+0.126454im -0.0605936-0.140879im 0.0439199+0.179985im -0.133792+0.300728im -0.0813352-0.137915im -0.0313941+0.148969im 0.0443316-0.0398547im -0.126248+0.0338931im 0.0660543+0.0243303im 0.00234137+0.0208722im 0.0640413-0.0416433im 0.140222+0.0855661im 0.0733194-0.0563213im 0.0799221-0.0247145im -0.121751-0.0715536im 0.043168-0.140678im 0.164056+0.141119im -0.167606-0.0549697im 0.25276-0.124916im 0.0806344+0.0408268im -0.354794+0.0612149im
-0.244497+0.144437im 0.0515967-0.0941111im -0.0131307-0.159989im 0.246449+0.129602im -0.0922696+0.282444im 0.0618634-0.0029504im 0.0461542-0.00163993im -0.0805372+0.000723118im 0.104298+0.0493868im -0.0131356-0.135087im 0.0444441+0.0892442im -0.137095+0.195338im 0.08183-0.042827im -0.0333259-0.112415im -0.0658522-0.0473672im -0.182027+0.129288im -0.0406853+0.0982042im -0.168787-0.134684im 0.166311+0.107283im -0.0353663-0.0639323im -0.11563-0.235695im 0.0439764-0.0900341im 0.0173298-0.000356459im -0.109056-0.246099im -0.26178+0.0913753im 0.068437-0.0365419im 0.0883846-0.114905im -0.025892+0.0829028im 0.0112611-0.21964im -0.0921127+0.0575791im 0.0089876+0.0641679im -0.18267+0.251216im
-0.0713692-0.165625im 0.0776543-0.0245796im 0.191124+0.364253im -0.0355634-0.129322im -0.130535-0.0198948im -0.00996467-0.022961im 0.112923+0.324796im 0.079359+0.0165344im 0.0366111-0.124188im 0.198186-0.0116595im 0.170131+0.0391681im -0.10147+0.190524im -0.123966-0.011256im 0.0645532+0.0982016im 0.00463911-0.190481im -0.030058+0.120659im -0.119072-0.00690073im 0.250738-0.0556512im 0.000794266+0.0356384im -0.00912202-0.0481321im -0.129433-0.0772601im 0.00277197-0.0370119im -0.0868577-0.0311137im 0.00210233+0.16288im -0.0247073+0.0390553im -0.0567033-0.0133923im -0.215806-0.159884im 0.0483765+0.17651im 0.00693662-0.108075im 0.211024-0.106586im -0.0881299-0.192983im 0.0690494+0.211838im
0.188677-0.00841418im 0.0735921-0.227942im -0.185201-0.00324989im -0.0393334-0.17337im -0.174219-0.119331im 0.0143508+0.0182727im -0.0575348+0.0189619im -0.0932005-0.000519583im 0.137955-0.121708im 0.0185511+0.0738739im 0.146879+0.0648325im 0.10013-0.168651im -0.14854+0.1278im -0.0258968+0.141889im 0.025903-0.161693im -0.051762-0.0156117im 0.0567321-0.0992977im -0.144345-0.182527im 0.00419548+0.0486486im -0.102657-0.0718901im -0.244609-0.163611im 0.20278+0.00676562im -0.099837+0.0270665im -0.00371248-0.0901414im -0.204558+0.132081im -0.292803+0.034253im -0.0375114+0.15623im -0.111375-0.0292378im -0.217729+0.0545329im -0.182547-0.11394im -0.113765+0.0105046im -0.0738433-0.241525im
0.102574-0.214404im 0.0798371-0.0898724im 0.135843-0.170036im 0.0132095+0.0672348im 0.00193048+0.0967847im 0.134724-0.19963im 0.0261635-0.112585im -0.00263601-0.215504im 0.198468+0.0681815im 0.0130558-0.0545888im -0.0871801+0.05981im 0.145729-0.0521015im 0.0515505+0.0662533im -0.0792669+0.0339533im -0.103782+0.276278im 0.0223959+0.306206im -0.172055-0.220747im -0.0296203+0.235825im -0.210596+0.245903im 0.0228203-0.12168im -0.124793-0.000115674im -0.0403966+0.14842im -0.047459-0.112052im -0.0211679+0.0781297im -0.00791095-0.0355948im -0.23017+0.117304im 0.0892441-0.0775033im 0.0221328+0.0995586im 0.137289-0.0381241im -0.0272175+0.0696725im -0.0971031-0.147605im 0.0798031+0.0128695im
-0.0727693-0.0474504im 0.0459527+0.0229523im 0.0235186+0.0683812im 0.0363511-0.0701897im -0.11077-0.397668im 0.209975-0.142579im -0.163436-0.270083im -0.0581506+0.137409im -0.317521+0.0492568im 0.00411427-0.140208im -0.0461873-0.108548im 0.160006+0.170005im 0.0201372+0.0474656im 0.0447944-0.119584im 0.0528826-0.00969215im 0.0593513-0.0347214im -0.138126-0.108858im -0.0683646-0.121597im 0.0471147+0.0761536im -0.0395991-0.146367im -0.0388913+0.186836im 0.0885528+0.115801im 0.155891+0.110908im -0.179688+0.0800731im -0.141546+0.0365928im 0.111199-0.0163723im -0.132715-0.0427602im -0.0586564+0.20871im -0.000690619-0.142807im -0.114414+0.060475im 0.13953-0.158037im -0.0797751-0.0298802im
0.0248527+0.140253im 0.0739728+0.0681774im 0.0482976+0.0903504im 0.283487+0.0270495im -0.222148-0.147128im -0.0626613-0.00869873im 0.078448-0.0315039im 0.0381418-0.336698im 0.183331-0.197364im -0.135316+0.013063im -0.128895+0.000182725im -0.108308+0.179195im -0.121114+0.125523im 0.0929065-0.00625524im -0.0114977+0.0622902im -0.0146561-0.13061im 0.210757+0.239343im -0.120618+0.03598im 0.156138+0.09379im -0.226372-0.015311im 0.00594218-0.0385807im -0.0417206+0.0866145im 0.0686015+0.0508551im 0.0332758+0.22278im 0.0605255+0.125487im 0.0304382+0.136595im 0.0224002-0.0409516im -0.0844741+0.0692615im 0.249709+0.204261im -0.0171868+0.0882153im 0.0166941-0.092562im 0.076066-0.135133im
-0.030999-0.152245im 0.063326+0.0321605im 0.011453-0.0730048im 0.033733-0.141247im -0.0919911+0.046726im 0.178247-0.03459im 0.132388-0.0367077im 0.166085-0.100092im -0.116873-0.0773248im -0.103092+0.187349im 0.0777946-0.0195764im 0.213753-0.155309im -0.0743672-0.145544im -0.194419+0.155912im 0.0763561+0.0937772im -0.358815-0.0854964im -0.238103+0.249924im 0.177634-0.139416im 0.0500934-0.0672321im 0.0992723+0.0995455im -0.0571408+0.0239972im -0.22124-0.132261im -0.0544129+0.0635935im -0.0734447+0.0386153im 0.074323+0.0819363im 0.111229+0.0137832im 0.0200949-0.124591im -0.136643-0.0897012im 0.0590422-0.0949001im -0.268682+0.14061im -0.0579644-0.0156511im 0.0277726-0.0753432im
0.0863323+0.21684im -0.178657+0.0322626im 0.0808478+0.0493623im 0.0967812+0.114402im -0.077061-0.135131im 0.225296-0.0768309im -0.211728+0.314328im 0.130818-0.138313im -0.0833972-0.0883195im 0.126906-0.0820353im -0.0203415+0.0118231im 0.137775-0.163542im 0.053627+0.138801im 0.132569+0.13748im 0.00489576+0.16311im 0.0360433+0.0697993im 0.178881-0.0171264im -0.0209989-0.129389im -0.0793481+0.00837212im -0.0347455+0.0101143im -0.0272843-0.0927578im 0.0268734+0.00897809im -0.24537-0.126716im -0.109153-0.0968387im 0.124261-0.0644708im 0.323285+0.137161im 0.172351-0.064688im 0.151884+0.01607im -0.136775-0.209266im -0.0722271-0.0830358im 0.0381024+0.0260847im 0.0573704-0.00924598im
0.0553838+0.085013im -0.152103-0.156224im 0.0274555-0.0878152im -0.118646+0.293091im -0.193072-0.0279532im -0.157751-0.0733291im 0.118158+0.0495618im -0.0650973+0.0441138im -0.0201092+0.0145815im 0.0393544+0.119631im 0.134057-0.130997im 0.163567+0.0231572im -0.244419-0.213471im 0.0261619+0.00631828im 0.00746277-0.178716im 0.275411+0.0246375im 0.0159791+0.0811906im -0.0522857+0.123109im -0.126947-0.080555im -0.191589+0.231882im -0.0813739-0.00846761im -0.00122392+0.0543667im -0.0233975+0.00294623im -0.132052+0.0673773im -0.0644328-0.184301im -0.05674-0.0144809im 0.0467449-0.0467034im -0.148874-0.16618im 0.24726-0.274953im -0.10159+0.0691525im 0.137434-0.0917256im -0.0524749+0.0426782im
0.0731087-0.0272328im 0.14566+0.0165994im 0.0663812+0.129071im -0.0421551+0.110229im 0.145587+0.0132142im -0.184513-0.0780255im -0.105385-0.0669426im -0.0294489+0.208881im -0.10816+0.0428076im -0.0457581-0.0535524im 0.0033956-0.326582im -0.074738-0.00267352im -0.211723-0.0130061im 0.0862717-0.0216095im 0.0814164+0.254267im -0.155402+0.220313im 0.0433018+0.0848733im -0.0172065+0.170357im -0.0641694+0.0710108im -0.111996+0.0928552im -0.0433543-0.179364im 0.0591836-0.309171im -0.0283031-0.127273im 0.113562-0.0321707im -0.201314+0.0952133im 0.17875-0.120686im -0.0369124-0.13122im 0.0270045+0.0936365im 0.0569123+0.0414704im -0.094463-0.130171im -0.0882755-0.00903152im 0.0733322-0.295216im
-0.0366908+0.0771518im 0.0204308+0.17771im 0.12713-0.20836im -0.19183-0.216438im -0.0977292+0.0113285im 0.20754+0.00910904im -0.0897997-0.135041im -0.110243+0.0469896im -0.0586644-0.0620411im 0.100509+0.269468im -0.0206181+0.0303257im -0.192412+0.0161508im 0.0387874-0.0857345im 0.0319698-0.103812im -0.159272-0.0101233im 0.434774+0.00314304im 0.0597747+0.0916832im 0.0493265-0.137406im 0.019343+0.134635im 0.0772649+0.0581852im 0.0144347-0.206698im -0.0708482-0.246377im -0.042335-0.217158im -0.0636253+0.00939803im 0.018002+0.0764425im -0.0239174-0.01898im 0.12525-0.115009im -0.0932986+0.0214899im -0.0665949+0.131858im -0.0249376+0.0708591im -0.0887835-0.234185im 0.0227136-0.037634im
0.150222-0.0785445im -0.03387+0.20323im -0.099522+0.168815im 0.0414351-0.0899344im -0.22842-0.0244782im 0.0910684-0.109466im 0.221636-0.035452im 0.101656+0.33106im 0.135649+0.0305874im -0.0869645-0.129703im -0.0395795+0.25489im -0.0675034-0.134802im -0.074065-0.138095im 0.130061+0.0237198im -0.224898+0.193946im 0.156353+0.0996155im 0.066766+0.119514im -0.00678468+0.0217103im 0.127016-0.0186434im 0.0831747-0.0810706im -0.0538801+0.0194212im -0.0237253+0.0446464im 0.0380533-0.132839im 0.0430774-0.226843im 0.0647434-0.0505117im 0.0256741-0.0220826im -0.238193+0.184726im -0.0397553+0.0392508im 0.175892-0.185941im -0.0425735+0.0617176im 0.0136797+0.16942im 0.0214162-0.0991472im
-0.178647+0.0791655im -0.02707-0.0408657im 0.0229186-0.0648067im -0.170882-0.167512im 0.0422956-0.102129im -0.174118-0.0280639im 0.0543019-0.136916im 0.182932-0.0855027im 0.132986+0.091986im 0.239879+0.0113947im -0.00955385+0.252238im 0.20808+0.00476336im -0.0176061+0.155558im 0.0439927+0.115922im -0.142508+0.173739im 0.0448728-0.0282522im 0.011039-0.0641448im 0.0742772+0.107475im -0.0469967-0.0046402im -0.0455474+0.189276im 0.112398-0.192075im 0.271797-0.125462im -0.106012+0.278926im -0.0491819-0.0215631im -0.0328231+0.0129158im 0.157449-0.112512im -0.194292-0.100519im -0.103222+0.113834im 0.072664+0.160171im -0.115717+0.0822669im 0.118684+0.132349im -0.0392497+0.143884im
-0.0279887+0.052295im 0.0291375-0.0576544im 0.212347+0.0380873im 0.0240175+0.0675314im -0.00907545+0.0848666im 0.0468536+0.0652118im 0.0123801+0.0451685im -0.171493+0.0364762im 0.159576+0.187462im -0.00519704+0.200727im -0.154156+0.0450794im 0.0510351+0.00946317im 0.075962-0.192428im 0.179848-0.161234im 0.209805-0.056335im -0.0832895-0.202914im 0.0139715+0.16498im 0.0644771+0.0464045im -0.209542-0.11165im 0.0778711-0.0257532im -0.232932+0.083233im 0.212196-0.000814025im -0.0164166-0.0320191im -0.169584-0.156349im 0.100802-0.0933568im -0.0751778+0.184561im -0.118846-0.0858013im 0.0208937+0.35863im -0.0954659+0.106647im -0.0993624+0.0662243im 0.0630666+0.106581im 0.18966-0.124036im
-0.187175+0.0597392im -0.148207-0.000782073im -0.0236227-0.147094im -0.00956714+0.124833im -0.0486686+0.0374136im 0.0581559-0.0108454im -0.0234851+0.157068im 0.166576+0.187178im -0.165369-0.151547im -0.00840857+0.0298209im 0.175695+0.100126im -0.120155+0.0455509im 0.0284233+0.166603im -0.215585-0.18025im -0.0214864+0.0666588im -0.0810743+0.0823697im 0.0647133+0.0378998im 0.157543+0.152295im 0.00679422+0.120217im -0.101502-0.0753573im -0.183408-0.103799im 0.128069+0.174623im 0.229202-0.0787646im 0.15855+0.170515im 0.248035-0.16766im -0.0982621-0.149517im -0.0633773-0.0833028im -0.153283+0.0302673im -0.194223+0.0684403im -0.205787+0.025927im 0.125267+0.0705993im 0.0524857-0.132554im
-0.0316046-0.0274105im -0.241388-0.0353964im 0.1353+0.113763im -0.00160268+0.150611im -0.0266422-0.138297im -0.126656+0.0945874im 0.0818083-0.128506im -0.13808+0.0323168im 0.0743694+0.162692im 0.0512011+0.139427im 0.14906+0.229475im -0.22558-0.0962718im 0.185442+0.193821im -0.320054+0.0170672im -0.000166931+0.2206im -0.0633709-0.00887153im 0.00632239+0.0201205im -0.170128-0.210346im -0.0030689-0.130624im -0.0812311+0.142338im -0.0154458+0.228901im -0.0600238+0.0536155im -0.0787786-0.162643im -0.164925+0.0250754im -0.0782012+0.0998814im -0.00042487-0.102543im -0.103824-0.178803im -0.015022-0.00522454im 0.0693172-0.03498im 0.0513528-0.198729im -0.048688-0.103535im 0.056408-0.0944217im
0.066732-0.0193876im 0.0289049+0.0885818im -0.0213481-0.0598754im 0.090721+0.0526828im 0.0616999+0.00137757im -0.317411+0.253596im 0.0304525-0.0624747im -0.046158+0.226195im -0.0770796+0.043557im -0.176885-0.0889821im 0.0793061+0.0930074im 0.138491-0.0472853im 0.122552-0.00403438im 0.125265+0.0670686im -0.0998003+0.0433484im -0.0353633+0.0554101im 0.0757481-0.00905945im 0.104346-0.163911im -0.160819-0.075207im -0.295738-0.287547im 0.028774-0.155727im -0.134206-0.0433198im -0.0955369+0.117452im -0.119167+0.0395995im 0.226933-0.132038im -0.00744768+0.115888im 0.00605175-0.0544755im -0.0455494+0.107125im -0.0434248+0.0257766im -0.0457605+0.139514im -0.222587-0.272741im -0.178096+0.045116im
```

and then generate the state $ψ$

`psi = P[:, 3]`

```
32-element Vector{ComplexF64}:
0.06572046484748441 + 0.03033399331542282im
-0.09316743260941532 - 0.05499305334884531im
-0.19295376340763387 + 0.008794219528556801im
0.1519807818081928 - 0.18341334908343118im
-0.0776482080882592 - 0.07812379430054915im
-0.2270578329633753 + 0.2271620000661688im
-0.033667697751459495 - 0.11740060235063257im
-0.02949042179947227 + 0.021335258751960098im
0.023348975051573545 - 0.003676057252883125im
0.322565752894367 + 0.0im
0.019676625518665763 + 0.07584919803016502im
-0.036703519156378296 + 0.10146397783035672im
0.013967173800133187 - 0.08276595346022156im
0.2224923508603629 - 0.09946219125149904im
-0.1828606016540513 - 0.10192880561326835im
-0.012405908120425666 + 0.06417434528021553im
0.17660913833513373 - 0.0650660986661203im
-0.09229656077695102 - 0.061559311658767636im
0.10310209664974068 + 0.06809602020662116im
0.06783411163054594 - 0.26592842952108764im
0.011730981426506781 + 0.12048565581707726im
-0.09912242773786759 - 0.07933607791232293im
-0.006906331555686479 + 0.1951869058916554im
-0.15223970558356872 + 0.2657277711510408im
0.09932382647983888 + 0.05403241520911994im
-0.20145931150458277 + 0.03990831128076797im
0.1197846154605415 + 0.15000407575812355im
-0.06806751724692221 + 0.04546936578235509im
0.21899425216677607 - 0.015847285823220907im
-0.06888626301251857 - 0.04262962763428157im
0.06159815992773677 + 0.10133743645348332im
0.21900256387796108 - 0.06487638099810054im
```

In the phase estimation process, we will feed the state to circuit and measure the first `n`

qubits processed by iQFT.

```
r = join(ArrayReg(psi), zero_state(N))
r |> PE(N, M, U)
```

```
ArrayReg{1, ComplexF64, Array...}
active qubits: 8/8
```

Since our phase can be represented by 3 qubits precisely, we only need to measure once

`results = measure(r, 1:N; nshots=1)`

```
1-element Vector{BitBasis.BitStr64{3}}:
011 ₍₂₎
```

Recall that our QFT's bit numbering is reversed, let's reverse it back

```
using BitBasis
estimated_phase = bfloat(results[]; nbits=N)
```

`0.75`

the phase is exactly `0.75`

!

*This page was generated using Literate.jl.*