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:

qft-circuit

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 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 ith 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, functions 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 <: PrimitiveBlock{2}
    n::Int
end

YaoBlocks.nqudits(q::QFT) = q.n

Now, let's define its circuit

circuit(q::QFT) = qft(q.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) = print(io, "QFT($(x.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,

  1. they are different by a factor of $\sqrt{2^n}$ with $n$ the number of qubits.
  2. the bit numbering will exchange after applying QFT or iQFT.
  3. 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:

phase estimation

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 subroutine here uses focus! and relax! to manage a local scope of quantum circuit, and only activate the first n qubits while applying the block inside the subroutine 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{2, ComplexF64, Array...}
    active qubits: 5/5
    nlevel: 2

first 3 qubits activated

focus!(r, 1:3)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 3/5
    nlevel: 2

relax back to the original

relax!(r, 1:3)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 5/5
    nlevel: 2

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 .

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.0288371-0.304818im      0.0318254+0.211884im     0.0712215-0.0435597im   -0.0779607-0.0256219im    0.00128445-0.109472im     -0.119595-0.0336818im      0.158633-0.0391118im   -0.0932399-0.165669im     -0.0570144-0.027765im      -0.130458-0.0240182im     0.255621-0.125804im     0.231672+0.0489338im   -0.0540529-0.009606im      0.266178+0.0465844im      -0.127294-0.259766im       -0.121775+0.120874im      0.0258644+0.0324726im     -0.113736+0.0295146im   0.00186736+0.0487231im       0.1692-0.0707951im   -0.0989409-0.0214521im       0.141792+0.0496568im       0.228978-0.0077436im      0.173109-0.0715331im     0.047692+0.234349im        0.14048+0.0450966im     0.0493552+0.0561012im    0.0600044+0.0789866im     0.0589948+0.0832576im      0.222679-0.162834im       0.160965+0.134369im    -0.0813517+0.0703692im
 -0.0161925+0.108238im      -0.218293-0.157456im     -0.263689-0.0148643im   -0.0563978+0.0256328im     -0.123663+0.0274693im    0.0507164+0.0542407im      0.115224+0.0414337im   -0.0099978-0.0507037im      0.034886+0.172779im     -0.0682651-0.0668734im   -0.0325234-0.289435im   -0.0669089-0.0903609im    -0.151355-0.257455im     -0.176009+0.14073im        -0.073871-0.13033im        -0.133626+0.19999im      0.00554172+0.225793im      0.0319796+0.137203im      0.109733-0.134459im     -0.149373+0.211164im     0.0530162-0.0295699im       0.058567+0.329381im        0.130406+0.0766451im   -0.00247037-0.183693im     0.0265913-0.130316im     -0.0289815+0.0105261im     0.0651996-0.10917im       0.107737+0.139245im      0.0679266-0.00278456im    0.0968607-0.0437275im     -0.126708-0.0611558im   -0.0154942-0.0542422im
   0.180873+0.157171im      0.0232433-0.0167136im    -0.393906-0.00581905im  0.00266352+0.0831642im      0.128727+0.0607714im   0.00373249+0.19762im      -0.0489122-0.0537572im      0.12316+0.0972113im    -0.0090984+0.138681im     -0.0620571+0.211276im     0.0874813+0.0861189im   -0.208046-0.0113422im    0.0648212-0.0680227im     0.233656-0.0420996im      0.0290788-0.213495im      -0.0451129-0.0207447im     0.0931577-0.0594753im    -0.0911719+0.0390037im    0.0639163+0.02949im      0.0465811-0.0589824im    -0.262047-0.13158im        -0.178427-0.124013im      -0.0370872-0.110032im        0.19044+0.0247008im    -0.121875+0.131124im      0.0250927+0.000321549im   -0.237738-0.0755531im      0.03509+0.0896511im    -0.0744193-0.1168im      -0.00205309-0.280656im      -0.109015-0.083463im      0.083691-0.0764775im
  -0.105997-0.0258179im     -0.369953+0.105792im     0.0360008-0.145728im     -0.149405+0.263467im     -0.0164972+0.0627681im    0.0174702+0.12296im        0.123158+0.189862im     -0.119589+0.183447im       0.110226-0.178095im      0.0769178-0.09269im     -0.0840023+0.092502im    0.0579528-0.19094im      0.0993208+0.0431854im    0.0748551+0.0137465im     -0.0893202-0.0917311im      0.0586424-0.103231im      -0.243997-0.111106im       0.119802+0.0197702im     0.158754-0.0151294im    0.0784893-0.0328791im   -0.0158756+0.0890862im      0.0151814+0.0906525im     -0.0370187-0.142369im       0.138623+0.181048im    -0.0462749-0.0245901im      0.168787+0.0333674im     0.0587087+0.29308im       0.148202+0.0919791im     0.0167419+0.0277844im    -0.0959191-0.0298161im     -0.250648-0.0886213im   -0.0405801-0.00128345im
 -0.0163502+0.110838im     -0.0563056+0.159886im     0.0888569+0.0183626im    0.0306618-0.090727im      -0.295233+0.0691844im    0.0645248-0.0468943im     0.0520334-0.155744im      -0.11236-0.0311836im    -0.0580226-0.0972624im    -0.0142546+0.0762756im    0.0626023+0.198191im   -0.0728252-0.17857im     -0.0949129-0.0893073im   -0.0497775-0.143858im        0.114515-0.218499im       -0.189069+0.258283im      -0.102105-0.0683665im    -0.0397632+0.0982941im   -0.0528824-0.00750929im   0.0645723+0.00168467im  -0.0433115-0.311172im       0.0201389+0.0700996im     -0.0599393-0.0889197im     -0.206114+0.0704903im      0.19092+0.194444im      -0.149178-0.0242698im     -0.103019+0.083839im    -0.0678827+0.189117im      -0.091624-0.0872228im     -0.241272+0.217802im     -0.0120444+0.0195577im    0.0422722+0.155895im
 3.51776e-5+0.132971im     -0.0438953+0.0375687im   -0.0555448+0.213563im     -0.146372+0.0206585im     -0.211413+0.109647im       -0.2982+0.0220812im      0.254639-0.0143373im    0.0732316-0.0247992im     -0.102267-0.00210467im    0.0684798+0.11764im      0.0264298-0.0820219im  -0.0852844+0.234162im     -0.133321+0.131518im     0.0699695-0.047543im      -0.0731045+0.0639267im      0.0691292-0.159403im     -0.0216183-0.136468im      -0.308973-0.14315im      0.0556523-0.190546im      -0.14863-0.0818814im     0.155193-0.0708031im       0.015934+0.0884529im     0.00105594-1.38938e-5im   -0.0544555+0.0288432im   -0.0145101-0.116147im    -0.00273467-0.0950801im     0.0514837+0.257266im     -0.185172+0.124353im      0.0250372+0.0660402im     0.0885549-0.0875004im   -0.00755496+0.0503999im     0.317835+0.0353627im
 -0.0850807-0.0201194im     -0.176886+0.249608im     0.0130447-0.0185441im    -0.151085+0.0718367im      -0.11443-0.265333im    -0.0674978+0.0539376im      -0.33467-0.110672im    -0.0532558+0.260603im      0.0668003+0.0821708im    0.00185988+0.0744856im     0.155637-0.0206085im   0.0479715+0.0249066im   -0.0502908+0.210583im     -0.117166-0.0118579im       0.115848+0.00411632im     -0.169503+0.227848im      0.0298573+0.0103345im    -0.0234563-0.181617im      0.083495+0.0651384im    -0.172533-0.125184im     0.0464646+0.0607266im      0.0588435+0.000921873im    0.0239152-0.0933325im     0.0513586-0.0329528im    -0.137784-0.146983im      -0.182271-0.0517319im    -0.0313848-0.106478im    -0.0760479+0.00466496im    -0.208304+0.179942im    -0.00102077-0.0706339im    -0.0823852+0.189199im    -0.0643986-0.222551im
   0.051226+0.0259008im      0.138755+0.222673im    -0.0237283-0.0514381im    0.0850894-0.135611im      -0.139934+0.209515im     0.0502811+0.0800511im    -0.0281393+0.0106998im     -0.29584+0.0436014im      0.120314+0.367723im     0.00671793-0.0707949im   -0.0448638-0.207454im    0.0143959-0.0379594im    0.0597541-0.101437im    -0.0717222+0.0426633im     -0.0461981+0.0631926im      -0.143659-0.117517im      -0.113625-0.0139086im    -0.0286245-0.20885im     -0.0445464+0.117367im      0.363593+0.0689627im    0.0652219+0.22687im       -0.0390303-0.0312079im     -0.0877871+0.13716im       0.0696269-0.0249395im   -0.0386218-0.0542566im     -0.112716+0.0783344im     -0.111723+0.156764im     -0.184509+0.0876515im     0.0436373-0.163971im     -0.0454191-0.0956482im      -0.08492+0.144088im     0.0288443+0.045842im
  -0.110299+0.0419303im     -0.175787+0.0293107im    -0.126177-0.0386746im    -0.103479-0.0484938im     0.0911345+0.154066im     0.0818383-0.0641232im    -0.0049329+0.0176366im    0.0482422-0.00737409im    -0.343349+0.0430024im     -0.115348-0.0581715im    -0.021718-0.0725255im    0.149721-0.00381026im   -0.129862+0.00390138im  -0.0536425+0.253822im       -0.087065-0.085916im        0.196866+0.119331im      0.0904436-0.160839im      0.0152987+0.118032im    -0.0867655+0.194385im    -0.0482437-0.173394im     0.0667465-0.0687734im     -0.0664728-0.0419449im      -0.160672+0.321885im     -0.0165173+0.0569685im    0.0136066+0.134418im      0.0580056-0.0784121im      0.144273+0.0562376im    -0.229703-0.0809927im    -0.0202803-0.0227391im     -0.306918-0.162653im     -0.0236237+0.0950106im   -0.0963363-0.189204im
  -0.144142-0.0658438im    0.00414381+0.0153443im    -0.162429+0.165882im      0.202789-0.0233527im    -0.0127672+0.140732im      0.135692+0.107655im      0.0225551+0.267954im    0.00167298-0.0609214im     0.0589349+0.0742769im     -0.403449-0.159994im     0.0993825+0.128269im     0.257278+0.119778im     0.0898224+0.107918im     0.0426008-0.0892684im      0.0289273-0.153243im       0.0647457+0.0235339im   -0.00258373-0.228285im     -0.0627359+0.0577736im     0.121237+0.151461im    -0.0312897-0.0256186im     0.029228+0.0291512im    -0.00312926+0.0537867im    -0.00672446-0.15216im         -0.1315-0.0285003im    0.0136443-0.210648im      -0.210077-0.0434789im      0.114294-0.0874274im     0.153165-0.0910983im     -0.100501-0.16024im        0.100021+0.103566im     -0.0454038+0.075181im      0.194528+0.0243891im
 -0.0880088-0.0293681im     0.0844287+0.00924521im    0.128511+0.116356im    0.00807162-0.106968im      0.0261938-0.148425im     0.0183345+0.124417im     -0.0748794-0.104431im     0.0969413+0.0594685im     0.0550432+0.0770714im      0.155938-0.0456491im    -0.119829+0.0969232im   0.0163693-0.0223003im     0.195494-0.109993im    -0.0216914+0.172539im      -0.0867917-0.222185im        0.153109-0.0427835im     0.0457634+0.191941im     -0.0118378+0.0260011im     0.222594-0.102421im     0.0827813-0.14144im      0.0230316+0.00468468im    -0.0208452+0.00141837im       0.18634+0.0793163im     -0.179159+0.249098im      0.152618+0.192968im      -0.325148-0.156432im       0.067645-0.00647935im  -0.0147115-0.111898im       0.198865+0.0693916im     0.0776425-0.151908im      -0.284995+0.0682039im      0.14741+0.00871887im
 -0.0663104+0.0619812im       0.11864+0.0836073im     0.149495+0.131691im     0.0149917+0.0413595im      0.115223+0.031553im     -0.248226+0.0168142im     -0.136459+0.169924im      -0.13622-0.0431295im     0.0216975-0.259698im      -0.155772-0.223174im      0.162085+0.0386944im   -0.251981-0.136143im     -0.235218+0.159209im     0.0717881-0.103053im      -0.0711387+0.00162236im      0.021543-0.0765378im     0.0212104+0.230049im     -0.0708531+0.236926im      0.111783+0.142746im    -0.0260681+0.237686im      0.174691+0.159499im      -0.0164271+0.00395348im    -0.0581683+0.141208im      0.0156316-0.011798im    0.00813847+0.147448im     -0.0799073-0.0568277im     -0.141292-0.0733171im   -0.0689334+0.113775im     -0.0541403-0.0863228im    -0.0283505-0.12009im        -0.11005-0.0822528im     0.057984-0.13618im
 -0.0443439+0.134636im       0.164552-0.0177868im   -0.0297225-0.117148im     0.0575554+0.0869116im    -0.0461891-0.0864659im    -0.271545+0.121553im       0.127297-0.159182im     0.0415607-0.0777937im      0.184306-0.0793245im   -0.00288193-0.232424im    -0.0875996-0.200427im     0.207827+0.137424im     -0.131259-0.0607021im    -0.033035+0.00999688im      0.127098+0.0413498im       0.152057-0.0603241im    -0.0569947+0.120846im      0.0237962-0.117395im      0.188688+0.0857037im    0.0377744+0.047034im      -0.24957-0.177271im       -0.079555+0.240172im       -0.158954-0.024852im    -0.00349232+0.180935im     0.0365977+0.035772im      0.0641114+0.0125931im    -0.0651366-0.0749051im    0.0271652-0.182907im      -0.322491-0.0254162im     -0.158899-0.0536545im     0.0170812+0.149102im    -0.0571607+0.0633572im
  -0.127343-0.0237891im      0.362153+0.297249im     -0.132019+0.0660459im    -0.279064-0.0902836im    -0.0648995-0.167927im      0.106442-0.0299585im      0.107932+0.00991923im   0.0956404+0.0399631im    -0.0216246-0.130004im     -0.0340647-0.0356047im    -0.151254-0.0210718im   0.0292712+0.0922484im   -0.0098526+0.106489im     -0.190251+0.0603752im      0.0477468-0.199079im       -0.129994-0.158741im     -0.0120908+0.00377313im     0.173541+0.0681996im    -0.131987+0.0885099im    -0.101157+0.0449162im    -0.154338-0.000359559im    0.0471958+0.0508082im       0.197269-0.0223973im     0.0343156-0.0788695im   -0.0844411-0.0714774im       0.13704+0.150596im     -0.0824791+0.0516874im    -0.107227-0.100919im       0.107614-0.109369im      -0.127408+0.098032im      -0.129438-0.197679im      0.206192-0.143252im
  -0.108537+0.0644494im     0.0858631-0.0538019im    -0.102753-0.0781765im     0.181646-0.136143im      0.0118857-0.14726im      -0.127221+0.0839257im     0.0517783+0.0165555im    0.0560564+0.176279im      0.0142652+0.0283265im     0.0747836+0.00968249im  -0.0945856+0.128532im    0.0435865+0.108266im     -0.145777-0.00738985im  -0.0611525+0.233033im       -0.255223-0.077146im      -0.0499011-0.119252im      -0.107775-0.139707im       0.267659+0.132788im     -0.305993+0.0667768im   -0.0322938+0.0107679im     0.168922+0.0818611im      0.0314831+0.129413im       -0.131773-0.166438im       0.119084+0.0292336im   -0.0900127+0.164856im      -0.227408-0.114203im     -0.0320817-0.0096821im      0.06411+0.235082im      -0.164959+0.156915im      0.0933506-0.0567805im      0.193014-0.0328972im    0.0322047+0.118441im
  -0.082518+0.237866im     -0.0187095+0.115727im     0.0949791-0.0148919im   -0.0909946-0.0594924im       0.20237+0.0718482im    0.0190887-0.1273im       -0.0125459+0.177397im     0.0142723-0.253606im     -0.0351948-0.00957962im    0.0713079-0.156368im      -0.25839-0.243866im   -0.0792585+0.0563724im   -0.0268242-0.0124325im    0.0916464+0.094412im      0.00128885+0.0242053im      -0.465131+0.11885im       0.0600968-0.179028im      0.0259472+0.076249im      0.184268-0.0428299im   -0.0463949-0.0287607im    -0.102937+0.032645im       -0.053694-0.28145im       -0.0868447-0.0858348im     0.0552883+0.102323im     0.0191845+0.0144078im    -0.0681048-0.116759im     -0.0167976-0.0152562im     0.105414-0.0674082im    -0.0533651+0.232217im      0.0324011+0.046101im     -0.0187053+0.0494361im     0.127738+0.099875im
   0.149141-0.245959im      0.0487101-0.165251im       0.15019-0.014581im     -0.194078+0.137447im      0.0257126-0.038119im      0.230182+0.0469363im     0.0378005+0.209154im    -0.0300433+0.0522512im     -0.179718+0.0705935im     0.0297649+0.043871im     -0.187953-0.0934746im   -0.226085+0.00808487im   -0.177135-0.0184559im    0.0863108-0.0783005im      0.0881597-0.273162im       0.0656213-0.123883im      -0.261203+0.103795im     -0.0470384-0.145707im     -0.050935+0.188768im      0.047257+0.137999im     0.0367617-0.118331im       0.0899474-0.0229888im      -0.089779-0.183693im     0.00233905-0.0606104im    0.0729972-0.0636577im     -0.100859-0.0341991im      0.142139-0.18966im      -0.124908-0.0779541im     -0.089038+0.138385im     -0.0818438-0.132562im      0.0596103+0.142052im     0.0982264+0.0689759im
  0.0215831-0.0969479im     0.0525643-0.0116533im    0.0729186-0.293045im    -0.0761958-0.108137im    -0.00500458+0.0277404im   -0.0386395+0.0460693im      0.060544-0.0741721im      0.12502-0.11649im        0.297897-0.227565im      -0.119283+0.0618803im     0.199162+0.0208111im   -0.179646+0.0804079im     0.166042-0.0312493im     0.092027+0.195016im       -0.139683-0.0600513im     -0.0164095+0.0627942im     -0.125468-0.195585im     -0.0134558-0.099753im    -0.0658722-0.0934597im    0.0702223+0.136808im     -0.130771+0.0751303im      0.0170126-0.0425545im      0.0230227+0.183577im      -0.168746-0.108366im   -0.00342238-0.27738im      -0.0527147-0.310224im      0.0746721-0.128647im    -0.0272805+0.0895318im    -0.0290064+0.0626204im     -0.257926-0.106347im     -0.0234988-0.0687613im    0.0111902-0.0310554im
   0.138776+0.0386307im    0.00222062-0.00742832im   -0.123885+0.0533583im    -0.196183+0.137327im       0.035965+0.0216958im     0.217574+0.0978711im      0.221523-0.238779im    -0.0404099+0.0862473im     0.0183974-0.0628839im    -0.0126023-0.278257im      0.152057-0.0220108im  -0.0183346-0.0431038im   -0.0283527+0.206393im     -0.193362+0.0947966im     -0.0547153+0.000685939im   -0.0501193-0.113138im      -0.114335-0.149141im      -0.117817+0.05747im     -0.0777611-0.051987im    -0.0619351-0.0813276im     0.106777+0.157015im       -0.195617-0.130987im       0.0290708-0.0139501im     -0.243202+0.0468747im     0.217607+0.0484564im     0.0761761+0.114672im      -0.215954-0.248837im     0.0237082+0.0185597im   -0.00258591+0.0858636im      0.155107-0.0610577im    -0.0278095+0.121104im     -0.166351+0.179137im
  -0.104758-0.353455im      0.0470245+0.0637392im    -0.124178+0.0828886im    0.0586958+0.150557im      -0.117742+0.0622634im    0.0388463+0.285211im      0.0883065-0.071589im    -0.0415243-0.424248im        0.18545-0.0941759im    -0.0488603+0.175796im    -0.0820036+0.045396im    -0.214658-0.0430602im   -0.0771778-0.0107613im     -0.20978+0.0300802im      0.0389987+0.102211im       0.0109814+0.0794778im      0.069196-0.00538027im     0.242165-0.0361556im    0.0914302+0.124236im     -0.114786-0.103938im     0.0980132-0.0942489im      -0.131873-0.168707im        -0.04563+0.0627585im      0.150476+0.184309im    -0.0347603+0.00408806im   -0.0389428+0.0619376im       0.12136+0.0251921im    -0.124815+0.106792im    -0.00556759+0.0390009im      0.135894-0.0193695im    0.00443572+0.0115319im   -0.0460351+0.0205765im
  0.0970524+0.0962839im    -0.0747152+0.010995im     0.0936959+0.105167im    -0.0421232+0.315095im      -0.249159-0.137307im      0.145258-0.0993054im      0.131701+0.117747im    -0.0679057+0.0286253im     0.0159243-0.107748im      0.0472463-0.086496im    -0.0227917-0.0523956im  -0.0151198-0.0140438im     0.185424-0.144805im     -0.120546+0.113442im      0.00244282+0.17301im         0.137834+0.0162067im   0.000372141-0.0625868im    -0.0512791+0.0857863im   -0.0556993+0.0949613im     0.110462-0.140282im      -0.11231-0.0587935im       0.135394-0.118816im        0.142323+0.233994im       0.223724-0.131574im     0.0616127+0.073602im      -0.187217-0.171573im      -0.146967-0.0504433im    0.0549996-0.00849738im    -0.276303-0.115489im       0.123338-0.0198036im      0.167677-0.0937377im      0.21706-0.0995601im
  0.0104867-0.138927im     -0.0762672+0.0232793im     0.151659+0.223692im     -0.164957-0.17773im       -0.197564+0.00759442im  -0.0547164+0.0798206im    -0.0888822-0.214463im      0.133643+0.265411im      -0.128497-0.089593im      -0.128904-0.211761im     -0.123144-0.0553659im  -0.0150066-0.0197572im   -0.0697622-0.222835im     0.0072771-0.148834im       -0.191392-0.0390253im      0.0396923-0.0700045im     0.0570181-0.168743im      0.0903081-0.0161876im     0.195827-0.00342504im    0.144585+0.148498im    -0.0342086-0.130693im       -0.327444-0.123643im      -0.0426828+0.0595308im      0.100738-0.069713im     -0.225949-0.0837429im     0.0170263-0.0801073im     0.0452853-0.0801873im     0.100298+0.0659405im     0.0745909-0.00671122im    0.0930331+0.135213im       0.130099+0.00757129im  -0.0728286-0.0213414im
  0.0199435-0.181434im    -0.00241522-0.146778im    -0.0805821+0.107408im    -0.0468952+0.0628879im    -0.0845453+0.128845im     -0.204447-0.0434807im    -0.0404587+0.0803695im    0.0051566+0.124352im     -0.0390962-0.0289669im      0.127574-0.00344755im    0.178664-0.0286734im   0.0931223-0.0268014im    0.0196773+0.0940049im    0.0743712+0.14923im          0.21466+0.107172im      -0.0675058+0.00974762im    -0.124689+0.0154643im      0.394059+0.245296im      0.151549-0.229701im      0.086185-0.116721im     -0.139439+0.0357637im       0.046924-0.0628775im     -0.0894051+0.0332303im    -0.0401713-0.190346im     -0.104792+0.0578267im   -0.00936542+0.0862258im     0.0226831-0.19625im      -0.157852+0.0488971im      0.105898-0.0788021im      -0.10929-0.00850935im   -0.0158786+0.237964im      0.245736+0.182112im
 0.00768472+0.00114685im     0.127721-0.0153815im     0.102176-0.174392im      0.139525-0.0345183im      0.118514-0.13443im       0.258914+0.213941im       0.073997-0.0151674im    0.0780642+0.0363735im     -0.133663+0.0677394im      0.161064-0.139233im     0.0814902+0.109934im   0.00438529-0.019372im     -0.259742-0.129702im     0.0502412-0.0769153im    -0.00222774+0.126321im        0.038889+0.137291im      -0.102533-0.146874im      0.0511252+0.054693im      0.269483+0.0931374im    -0.177825+0.0132316im   -0.0525699-0.0197279im        0.28677-0.0396305im      0.0960729+0.119589im      -0.155207+0.0497199im     -0.23518-0.139827im       0.110304-0.0878646im      -0.25149+0.178949im    -0.0748165+0.0950713im     0.0830166-0.103233im      0.0971987-0.0849058im      0.055207+0.116816im     0.0576955+0.0340684im
 -0.0701637-0.105028im      0.0529247-0.0192737im    0.0440205+0.134602im     0.0272792-0.115601im      -0.108286+0.109812im      0.178341+0.119499im       0.221256+0.129019im    -0.0139519+0.194378im    -0.00607508+0.115265im      0.0693417-0.184195im      0.120548-0.0328378im   -0.106599-0.00984117im   0.0618816+0.11382im       0.260946-0.000304797im   -0.0598526+0.23465im        -0.078426+0.23616im       0.0976844+0.135104im     -0.0112049+0.0782976im    -0.148624-0.0521626im    0.0142869-0.0137182im     -0.15582-0.00585138im     -0.121336+0.179207im       0.0911445-0.0820272im     0.0389848+0.234645im     -0.124915-0.00460581im   0.00376743-0.0932314im     0.0848612-0.0625632im    -0.321599-0.139378im      -0.163271+0.131144im      0.0075547+0.0351186im    -0.0420475-0.261448im     -0.104697+0.0462716im
   0.114002+0.117798im     -0.0323654+0.0459122im    0.0908212-0.0787058im    -0.174193+0.162088im       0.222109+0.0642092im      0.12064+0.0464289im    -0.0167076-0.115872im    -0.0702656-0.0778476im     0.0837634-0.0622318im     0.0570991-0.0642878im     0.120876-0.0447175im    0.173004+0.005374im     0.0412055+0.0468974im     0.064657+0.00516911im     -0.140335-0.184407im       0.0399153-0.0579709im      0.215102+0.21007im        0.160394-0.0328184im     0.012565-0.0353462im    -0.116086-0.0293505im    0.0639469-0.149084im       -0.111345-0.0395282im      -0.105528-0.0333515im    -0.0520515-0.310872im     -0.176601-0.0922927im     -0.295681+0.0012459im     0.0298417+0.279726im     -0.204649-0.0553053im     -0.108257-0.109849im      0.0660505+0.0381104im     0.0428598-0.141214im    -0.0425158+0.28847im
   0.114663-0.0161515im      0.141532+0.19058im     -0.0880075-0.0313725im    -0.170863-1.64745e-5im    -0.104878+0.0895686im     0.126363-0.166386im       0.122904+0.0633166im    0.0728671-0.0535804im      -0.15461-0.0601003im      0.218437+0.132931im    -0.0226007+0.157447im     0.201861-0.140939im    -0.0228935+0.00986381im   0.0798252-0.106473im        0.190405+0.0139209im     -0.0301339-0.0519868im      0.296875+0.10349im         0.13793+0.0151648im    0.0943231+0.0235259im    0.0954843+0.0754634im     0.074103+0.214664im       -0.149114+0.193697im      -0.0778949+0.0797066im    -0.0911478+0.164639im     0.0573829-0.221167im     -0.0591092-0.159972im      0.0404365-0.0702807im     0.213545+0.192116im     -0.0987155+0.0242012im     0.0124523-0.239966im       0.153062+0.0256238im   -0.0168479-0.0284263im
  -0.173594-0.0297919im       -0.0454+0.0357429im    -0.141813+0.0531512im    -0.212951+0.0349833im      0.135594+0.18221im      -0.114153+0.0630671im    -0.0624039+0.0230929im   -0.0121872+0.035644im     -0.0579957+0.0916054im    -0.0455017-0.0449282im    0.0197819+0.330387im    0.0711433+0.126971im      0.190131-0.283713im     -0.174465-0.148133im      -0.0810487+0.126093im     -0.00511737+0.0710713im   -0.00320509+0.0991917im     0.0301938-0.0168085im   -0.0208144-0.02685im     -0.0388702+0.345744im     0.0282547+0.0200107im      0.0734526-0.153364im        0.246577+0.0245336im    -0.0189366-0.0115934im    0.0794374+0.0609714im     0.0948996+0.0832889im    -0.0412781+0.0811807im   -0.0656989-0.0711242im     -0.246022+0.231228im      -0.125454-0.137435im      0.0989443+0.0982591im     0.104471+0.175126im
 -0.0384135+0.0103927im     0.0434384+0.0172283im     0.175969-0.178482im     -0.101411-0.00768276im    -0.240239-0.0620949im     0.107571+0.101526im    -0.00538632-0.0919387im    -0.128446-0.125237im      0.0742128+0.280939im     -0.0299435+0.0745063im    0.0617981+0.0561489im  -0.0516691-0.00128291im  -0.0256499-0.0446185im     0.220243+0.0887015im      0.0251544-0.0403789im       0.147605-0.0858275im      0.137251+0.0480149im    -0.0353462+0.215347im    -0.0842138-0.00553087im   -0.105402-0.0230007im     0.206023+0.0671631im      -0.137621-0.0211839im     -0.0764881+0.100836im     -0.0183409-0.0818173im    -0.206795+0.0892168im      0.258682+0.0235642im    -0.0438194-0.0481844im     0.254065-0.119325im      -0.170206+0.184828im     -0.0776182+0.207701im      -0.170948+0.106012im      0.272812+0.0515642im
   0.208322-0.23983im       0.0921881-0.0152852im    0.0994511-0.0200306im   -0.0311457+0.031805im     0.00560761+0.134148im    -0.0331525-0.0238357im      0.112916+0.163007im     -0.130869+0.235486im      0.0331932+0.00401354im    -0.163789+0.152929im     0.0552078-0.0516132im    0.285315+0.0695762im      -0.1642-0.12379im      -0.113007+0.0674162im     -0.0648081+0.0740648im      -0.095289-0.0252502im       0.11452+0.0724698im    -0.0423995-0.207331im    -0.0145394-0.0830301im    -0.360736+0.0400871im   -0.0358862-0.0346986im      0.0441311-0.158585im      -0.0782374+0.0352075im      0.103615+0.179095im     0.0289243+0.157163im     -0.0608474-0.222361im      -0.166006-0.0864375im     0.152553+0.0262473im      0.121841-0.0794431im     -0.145473+0.0740302im     -0.183489-0.11057im     0.00370611+0.105137im
 -0.0861671+0.181401im      0.0819814-0.101114im      0.053731+0.0778936im     0.188448+0.122638im       -0.10939-0.0110733im    0.0238636-0.0696504im     -0.108853+0.0906101im     0.137727+0.0166134im     0.0888471-0.0336485im     0.0399144+0.049606im    -0.0248357-0.0239883im    0.248393+0.0175076im    -0.216351+0.0620391im    0.0612657-0.255041im      -0.0444817-0.186326im      -0.0448648+0.0547829im     -0.140964+0.0308271im     0.0995688-0.00358106im   -0.246173-0.102745im      0.114311-0.0536767im    0.0630657-0.135282im      -0.0681705-0.23233im         0.160583+0.332224im       0.101185+0.072371im     0.0129388-0.227543im       0.110824+0.039286im      0.0295994-0.0752833im   -0.0320349+0.0651886im     -0.085351+0.105387im      0.0743253-0.13957im       -0.294688-0.0309336im   -0.0648718+0.159932im
  -0.227467+0.0955863im     0.0410215-0.149753im     0.0189339+0.16349im      -0.128997+0.0867061im    -0.0378814-0.116694im    -0.0736558-0.00860225im     0.109337+0.0721053im    -0.142424+0.0950858im      0.056013+0.0645188im     -0.192205+0.0106248im    0.0435314+0.0647086im   -0.182896-0.0738377im   -0.0152026-0.0737487im    0.0273021-0.023349im        0.161614+0.0198519im     -0.0890435-0.138882im      0.0629511+0.0613639im   -0.00529093+0.0476185im    -0.254154+0.108564im     -0.107189-0.0683515im    -0.379941+0.019384im      0.00127062-0.0231106im     -0.0959893+0.184418im      -0.174748+0.0257881im    -0.129416-0.0723614im      -0.16534-0.0102914im     0.0752648+0.263569im      0.208684-0.0190655im      0.191475+0.0926992im     0.0276136-0.102952im      0.0641667+0.213851im     -0.206246+0.0834813im

and then generate the state $ψ$

psi = P[:, 3]
32-element Vector{ComplexF64}:
  -0.03864843902792416 + 0.18232797980898932im
   -0.2975106155806648 - 0.09361628564224098im
  -0.16263494078749685 - 0.16490252894193955im
  0.004974082222167718 + 0.06663343869698107im
  -0.11732273320027918 + 0.03747342607126164im
   0.09255590613382426 + 0.04816112584402389im
  -0.06462427372462232 + 0.052897607428847346im
   0.03609621032356204 - 0.2223190727714371im
  0.011795946172726224 + 0.17470055183937305im
   0.04630340569688758 + 0.09950041231605984im
  -0.03777056736745889 - 0.006871355232008246im
   0.13892121732550985 - 0.20235226708137147im
   -0.1405647749324914 + 0.04181085592117031im
   0.19531294303609953 - 0.09067932807927889im
   -0.2006531731277597 + 0.11677927917523735im
   0.11478948693298537 - 0.0007198509307008369im
   -0.0631302846316558 + 0.1277459607358058im
  0.006918373873643545 + 0.0629763415609184im
  0.005099844401428926 + 0.05048847012792642im
  -0.03982344252795772 - 0.12597831608888954im
   -0.0992375501606598 + 0.09037523250171589im
   0.23369112639540354 + 0.19973240697847106im
   -0.0415488140553318 - 0.04944699734004299im
  -0.12155886828235876 - 0.029700148681629734im
    0.2663951435244987 - 0.010805523483287692im
 -0.025940849659648352 - 0.03100638490767335im
   0.12424250343342658 - 0.08372997703095655im
   0.07973493473514354 + 0.2043786920000804im
  -0.14284510369030132 - 0.17102758711635585im
  -0.02818253031293093 + 0.0048588362757192635im
   0.33424405851865335 + 0.0im
  -0.06616289271094541 - 0.013490267059876255im

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{2, ComplexF64, Array...}
    active qubits: 8/8
    nlevel: 2

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{DitStr{2, 3, Int64}}:
 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.