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.0396025-0.0158655im   0.0656942-0.0499195im     -0.138147+0.158008im     -0.00150251-0.168349im      -0.195073+0.141565im       0.0567965+0.0398383im      0.193335+0.0350007im     0.0737053-0.158366im    -0.0337143+0.152057im     -0.0423762+0.0546685im     0.0705686-0.250419im    0.0537649+0.223476im      -0.119311+0.17426im      0.0873365+0.229512im      -0.014158-0.245524im      0.191171+0.00753691im    0.0918252-0.163937im     -0.132798+0.102234im    -0.00156652-0.0812976im      0.102927+0.124687im      0.0692302-0.0540544im     0.110689+0.040577im     0.00746379-0.196735im      0.0276733+0.175306im      0.302907-0.00865729im  -0.0212751+0.0484799im      0.0301463+0.093529im    -0.0706206-0.00900483im    -0.00185745-0.227703im    -0.0212196-0.0472772im      0.143668-0.0659544im       0.122313+0.208656im
   0.0122842-0.0152551im  -0.0975464-0.0413695im      0.196958-0.00129991im      0.074887-0.151624im       0.168261+0.00510098im      0.140805-0.0917902im     -0.144857-0.183999im     -0.0518958+0.0596213im    0.0150926+0.0376574im     0.0551546-0.103509im     -0.0679389+0.235284im    -0.118807+0.0808681im     0.0356401-0.110422im     -0.171822-0.0915623im     -0.191808-0.182938im      0.129405-0.0728308im     0.0232378+0.00775805im   -0.161867-0.171007im     -0.0826962-0.146393im      0.0684536+0.143204im       0.105721+0.222676im    -0.0312487+0.00224559im   -0.0531552-0.17348im       0.0148167-0.0625139im   0.00963547+0.110887im      0.116584+0.123143im        0.017952+0.187468im     -0.325371-0.00244446im      -0.202082+0.179459im     0.0806763-0.117809im       0.166979+0.115322im     -0.00308123+0.195475im
   -0.224029-0.110761im     0.100442+0.235425im       0.182436-0.0921263im    -0.00207522+0.339972im     -0.0668182+0.183288im      -0.0719995+0.0259031im     0.0955805-0.100929im       0.148605-0.00512738im  -0.0895723-0.131098im      0.0487035+0.0610479im      0.127936-0.146807im    -0.159058-0.0119018im     -0.232473+0.00182463im   -0.110127+0.00811904im   -0.0901625-0.156543im     -0.057032+0.0446058im      -0.18508-0.0406807im    0.0322675+0.00344394im     0.149316-0.024365im      -0.105198-0.00516074im    0.0317375+0.0672027im     0.145941-0.256696im       0.111632+0.11226im       0.0229204-0.00575539im  -0.0290035-0.0799702im     0.105818-0.0418802im       0.304456-0.0259684im    -0.177351+0.092114im        -0.134208-0.0465592im    -0.179288-0.0541332im      0.132533+0.100775im      -0.0496417-0.0482136im
    0.127134+0.109595im    -0.309683+0.182345im      -0.107551-0.106523im        0.309998+0.193452im    -0.00370764+0.120099im      -0.0450874-0.159371im     0.00516276+0.025191im      -0.190132-0.108692im    -0.0161806+0.0424511im      0.243205-0.040936im    -0.00162334+0.038318im    -0.120333-0.0864537im      0.128758+0.0280354im    0.0349236+0.0772576im     0.0130777+0.0197357im   -0.0254138+0.0299639im   0.000537688-0.0402941im    -0.140528+0.0957238im      0.157391+0.0784768im      0.270488+0.0551121im      -0.19104+0.0486152im     0.250674-0.0229044im    -0.0784933-0.0358923im   -0.00255557+0.0245741im    0.0372679-0.0701131im    -0.200855+0.184605im        0.039158-0.0204065im     0.193963-0.000282631im      0.118349+0.167637im    -0.0275631-0.0956455im      0.231961+0.0904444im      0.0142675-0.0178084im
  0.00512642-0.213487im   -0.0117111+0.00696879im    -0.045677-0.0726499im     -0.0696877-0.00384887im    0.0835139+0.137609im       -0.274344-0.00694411im    -0.148123+0.0235242im    -0.0282266-0.106699im      0.127187-0.00346195im     0.202709+0.222601im      0.0427689+0.0667633im  -0.0840331-0.104113im       0.130443+0.17786im      -0.166776+0.0624366im     -0.142741-0.186427im     0.0722752+0.02344im       0.0442811+0.150407im      0.202821+0.113739im       0.214133-0.0830013im     -0.248786-0.0670578im     -0.115033+0.0702126im   -0.0626922+0.292724im      -0.205139-0.0437142im     -0.137527+0.0312123im     0.105804+0.0896399im   -0.0107311-0.0510985im      -0.129598-0.103345im     -0.146566-0.0198707im       0.0853037+0.0245065im    -0.191653-0.0735598im    -0.0727789-0.156668im       0.0375452+0.108466im
 -0.00522413-0.138379im   -0.0234199-0.083908im       0.188496-0.227525im       0.0323212-0.0401073im      -0.23592-0.137943im        0.310665+0.122511im     -0.0570853-0.0202576im     -0.257342+0.00454066im   -0.110708-0.0273556im     0.0261406+0.0223357im    -0.0726273-0.185996im     0.249288+0.0725526im      0.127806-0.185745im       0.06172+0.0886276im     0.0370741-0.0137183im    0.0873564+0.0041791im     0.0284884+0.00908044im  -0.0251059+0.09148im        0.231888+0.00279675im    -0.171183+0.0123224im     -0.053085+0.0445647im    -0.122326-0.0118839im     -0.157509+0.0371286im     0.0872295-0.199033im     -0.168902+0.101203im     0.0337714+0.122834im      -0.0141092+0.00503456im   0.0365022+0.188361im         0.141955-0.186408im     -0.226612-0.0972573im       0.11001+0.140367im       0.0349594+0.082238im
   -0.185178+0.15615im     0.0372677+0.232707im      0.0135183+0.0300387im     -0.0418512+0.0417209im     0.0377356+0.0876336im      -0.163471+0.0799179im      0.128693-0.090642im     -0.0942857+0.056713im     0.0531736+0.00610594im    -0.069742-0.165674im       0.059546+0.0400168im     0.20994-0.1399im         0.138104+0.250013im     -0.108881+0.0533976im      0.108624+0.130125im      0.348633-0.023462im       0.128413+0.0268222im    -0.142275-0.116389im      -0.148876+0.0266112im    -0.0036652+0.125546im     -0.0192948-0.070356im    0.00706551+0.0819866im     0.0747054-0.0446618im     0.0466018-0.219266im    0.00490304+0.193364im      0.173398+0.0234473im      0.0357073-0.136278im    -0.0072984-0.170204im        0.0181823-0.0664411im    -0.181448-0.268474im     -0.0218974+0.102876im        0.116523-0.200441im
   -0.072788-0.0608033im   0.0255583-0.135614im      -0.162288-0.163775im       -0.129704+0.134361im       0.193133-0.148687im       -0.180105+0.0924498im     0.0252627-0.134991im      0.0199124+0.0414029im    0.0338222+0.0181604im        0.0197+0.0595349im    -0.0267019+0.140726im    0.0200401-0.0508982im    -0.0498676-0.136063im      0.137057+0.237253im        0.10596-0.259635im    -0.0790845+0.295636im      -0.108453+0.00559211im  -0.0968463+0.0475453im     -0.148508-0.101175im       0.124962+0.0222989im      0.195959+0.0671064im   -0.0179484-0.171297im     -0.0985558-0.136233im     -0.0198083-0.10574im      -0.101306-0.0420004im     -0.17115-0.0545477im      -0.175668+0.158182im      0.205934-0.0373632im       -0.136921-0.0911331im    -0.183357-0.262941im     -0.0553785-0.030584im       0.0459564-0.0335018im
  -0.0886955+0.0295919im   0.0504498-0.0241401im      0.075496-0.030319im       0.0331367+0.0977627im     0.0923744-0.150505im       -0.217255-0.0349996im     -0.161291-0.0136763im     -0.180832+0.0308671im   -0.0189465-0.0582423im      0.102688+0.126088im     -0.0280886-0.0593539im   0.0712404-0.0652919im     -0.169987-0.0629038im     0.196185-0.102536im     -0.0245745+0.029909im     0.0532549-0.119333im      -0.110397-0.263615im     -0.288512-0.0664494im      0.140762+0.144984im     -0.0195329+0.0795344im       0.05493+0.1395im       0.0223352+0.0176526im      0.170939-0.161241im      -0.134671+0.0732288im    0.0617092+0.0876723im     0.104198+0.254674im       0.0958475-0.16542im      0.0634048-0.0160457im       0.0422177-0.0779563im    0.0332147+0.0583282im     -0.388563-0.137176im       0.0135217+0.240519im
   -0.044496-0.0470495im   0.0991995+0.0748008im    -0.0834519+0.076379im        0.100127-0.0104706im    -0.0209691-0.194252im       -0.100734-0.0475395im     -0.227387-0.0358439im      0.187545+0.0830502im    -0.166303-0.178877im       0.145761+0.153255im       -0.15969+0.136286im     0.155852+0.0114296im    -0.0711307+0.00694848im   -0.201645-0.0817299im    -0.0109832+0.0938747im     0.272162-0.0785118im      0.247983-0.115794im     0.0684079+0.182794im      0.0572844+0.0942274im      0.101466-0.0118278im    -0.0610613+0.242903im    -0.0905035-0.0465664im     0.0473938+0.0547763im      0.340113+0.0356846im      0.15878-0.108213im     -0.182856-0.15179im        0.0194641+0.0612536im      0.11981+0.0484812im       -0.141218-0.145972im     0.0179098-0.0517619im     0.0611324+0.0145373im     -0.0485783-0.0403206im
  -0.0186831+0.155764im   -0.0898162+0.252041im      0.0055127-0.0782im         0.0663974+0.130622im      -0.270431-0.0150116im   -0.000812968-0.0224427im     0.0640818-0.0366419im     -0.147169-0.0733464im    -0.159868-0.0557828im    -0.0112041-0.00765175im    0.0193712+0.0955912im    0.152598+0.1833im        0.0185356-0.153742im    -0.0285467+0.0090227im    -0.0891889-0.0770771im    0.0131089+0.00832114im    0.0138091-0.0107809im   -0.0221354-0.0037524im     -0.331169-0.0777977im     -0.243313-0.14952im      -0.0829724+0.131664im     0.0729042-0.0255077im     -0.237114-0.193433im      -0.158281-0.137563im       0.11262-0.226389im     0.0170194-0.268329im      -0.0198645-0.139369im     0.0297045-0.195066im       -0.0295351-0.0158234im     0.134991+0.0922074im     -0.110405-0.0400401im      -0.113357+0.14214im
  -0.0453571+0.0592441im     0.09417-0.0964479im     0.0821477-0.18186im        -0.109855+0.0344131im    -0.0214049-0.0228254im      -0.103448+0.0230107im      0.422124-0.123618im       0.245843+0.0313733im   0.00337764+0.0184509im      0.269332-0.0701154im      0.167699+0.0269994im    0.239575+0.134569im      0.0678103-0.0787211im    0.0859145-0.221144im       -0.14127-0.011873im     -0.218691-0.0239549im      0.195878-0.0619295im    -0.123867+0.0304629im         0.114+0.105451im      0.0296382+0.0473144im    -0.0168198+0.0776616im   -0.0622582+0.076221im     -0.0503955+0.0480718im      0.159755+0.0904437im    -0.011799+0.102174im     0.0747683+0.0263386im      -0.174207-0.052258im     0.0439031-0.203565im       -0.0103282+0.211355im     -0.109222+0.101751im       0.152086-0.094061im      -0.0449264+0.0609802im
   -0.127344+0.0327491im  -0.0812538+0.206034im     -0.0286576-0.0820823im      0.0499661-0.142563im      0.0702781+0.0979173im       0.186356+0.052462im     -0.0524656+0.0533715im      0.194236-0.0494153im   -0.0609906-0.0432599im     -0.134758+0.040859im       0.253472+0.221011im   -0.0202837-0.166004im       0.286818-0.14542im       0.117935-0.117868im     -0.0930086-0.00287522im   0.0418257+0.191644im    0.000171754-0.0336838im     0.137677-0.0251883im      0.227459+0.168129im      -0.133001+0.236945im      0.0786252-0.239203im    -0.0506146-0.204278im     -0.0121333-0.21334im       0.0807972-0.0079546im     0.183998-0.102015im     0.0797489+0.0534023im     -0.0316559-0.024372im      0.110104+0.0725107im      -0.0670451-0.0694228im    0.0994379-0.0647436im    -0.0531608-0.147663im       0.0299616+0.0692165im
   0.0819682-0.112967im    0.0260785+0.269619im    -0.00497728+0.194489im      -0.0500412+0.13409im      -0.0907186-0.139635im       0.0474622-0.236686im      -0.150177+0.0324101im      0.164742-0.171997im      0.286677+0.0386241im     0.0337243-0.176002im     -0.0632732-0.0116257im    0.173452+0.222953im      0.0993552+0.0877368im   -0.0431237-0.139361im      -0.039439-0.00463526im  -0.0627778-0.0802695im     -0.267193-0.0347555im    0.0502529-0.0512104im   -0.00328914+0.0191191im   -0.00744948+0.181569im      0.0298333-0.00617815im  -0.0435664-0.120256im       0.197438+0.00657233im    -0.155715-0.0684865im    0.0396632+0.0190995im   -0.0861623-0.0407289im      -0.332908+0.051518im     0.0693533+0.0413165im         0.04046-0.0383685im    -0.259913+0.00735671im  0.000917795+0.130894im       -0.027919+0.126099im
   0.0262303-0.199292im    0.0759196+0.226795im      -0.259332-0.147872im       -0.142872+0.0190824im     -0.108705+0.120011im        0.173658+0.210264im     -0.0141784+0.00284624im   -0.0226332-0.291107im    -0.0731953-0.21787im       0.0118933+0.125141im      -0.111183+0.168033im   -0.0537981-0.0684994im     0.0877166+0.097248im      0.142356-0.114816im       0.137876+0.147664im    -0.0745638-0.0141754im     0.0676361-0.259737im    -0.0268095+0.00461995im    -0.208437-0.146217im       0.146289-0.026566im       0.013717+0.0856309im    -0.179944+0.057361im       0.032331-0.0154349im    -0.0665898+0.272488im     -0.184578+0.0352094im      0.13409+0.0506819im      0.0240512-0.0434967im    -0.096275+0.0608746im      -0.0169835+0.106235im    -0.0604002-0.104989im      0.0363147+0.0498922im     -0.0410477+0.0809593im
   -0.217381+0.0272833im    0.169713-0.108466im       0.164284-0.00154221im    -0.0852689-0.100772im     -0.0718082+0.0387413im      0.0703117-0.0747008im      0.106612+0.0456812im   -0.00664032+0.111737im      0.209249+0.0229272im     0.0173534+0.149312im     -0.0180387+0.175534im     -0.12026+0.0339155im     0.0195622+0.0690061im    0.0732362-0.0129982im    -0.0160598+0.427799im      0.212215+0.359805im     -0.0583085-0.190234im     -0.028028+0.111594im      0.0896767-0.0780937im     0.0960021-0.172416im     -0.0080208+0.0199029im     0.191778-0.0893308im    -0.0698299-0.030564im      -0.150587-0.135087im     0.0386574+0.0503276im    -0.205186-0.0569011im     -0.0693137-0.0698883im    -0.124608-0.0204926im     -0.00242689+0.0308994im   -0.0443116+0.122832im      0.0627899+0.121392im       -0.043836+0.173996im
   0.0536196+0.156527im     0.102567-0.137767im      -0.118797-0.137313im       -0.194462+0.140024im     -0.0807353-0.139588im       0.0944986+0.0136834im     -0.192192+0.167958im      -0.200335-0.0324235im    0.0827598+0.13682im      -0.0170391-0.0554598im     0.0019267+0.0625296im   0.0493883+0.0706902im   -0.00375815-0.0968888im   -0.0769582+0.18692im      -0.0683095+0.148013im     -0.035063+0.132124im     -0.0978638+0.0869395im    0.0808478+0.108132im      -0.014304+0.0939789im     -0.101003+0.0501233im     -0.241103+0.040955im     0.0678922-0.0625054im       0.24208+0.0623035im       0.10225+0.201393im      0.134008-0.079812im      0.164085+0.175171im      -0.0361613-0.0698978im    -0.187467-0.249586im        -0.269328+0.0212322im   -0.0270942-0.172254im        0.14522-0.155132im      -0.0325888-0.0368428im
    0.173713-0.0941485im  -0.0969802+0.115365im       0.245077-0.300578im      -0.0199079+0.1088im        0.0381199+0.04201im        0.0114028-0.0226942im     -0.042869+0.0856721im    -0.0271773+0.159264im     -0.117365+0.0888977im     0.0849304-0.0297937im       0.20518-0.15995im     -0.038279-0.0754359im    -0.0608423+0.121472im     0.0458682+0.049085im      -0.172294+0.134869im     0.0738334-0.0507177im     -0.150967-0.129697im      0.229505-0.151868im      -0.200793-0.00756387im     0.208058-0.0881505im    -0.0217508-0.0420098im    -0.118701-0.00263608im   -0.0283813-0.229205im       0.172163+0.121313im     0.0149217+0.240371im     -0.129605-0.0337763im      -0.183388+0.099457im    -0.0640054-0.0721881im        0.016785-0.249001im     0.0386096+0.0407356im    -0.0183748-0.0708461im      -0.161468-0.0807798im
    0.208943+0.213568im   -0.0129223+0.103502im      0.0841076+0.0578229im      0.0292053+0.204753im      0.0479442-0.061779im       -0.131863+0.00295937im      0.18677-0.00704145im   -0.0914956+0.106569im     0.0375852+0.0472929im     -0.179882-0.123426im      -0.189958+0.234213im   -0.0286017+0.0516572im    -0.0498543-0.0492216im    -0.162039+0.000277001im    0.106648-0.0037122im   -0.0643053+0.051877im      0.0394824-0.181159im     0.0755104+0.0338127im      0.066364-0.170446im     -0.0511731+0.111936im      0.0326567-0.318079im     -0.153362+0.101872im      -0.216225+0.102597im       0.168683+0.141624im      0.030749+0.0358907im    -0.135645+0.126002im         0.14365-0.081779im    -0.0718867+0.152618im        -0.104177-0.105924im     -0.197329+0.0436235im    -0.0760594-0.0638354im      -0.133711+0.242357im
   0.0222166-0.136938im    -0.117402-0.126865im      -0.108954+0.126319im      -0.0372302+0.198763im       0.130153+0.185544im       -0.156235+0.0819938im     0.0156629-0.0369044im    -0.0490793-0.0760108im     0.179391+0.0270259im     0.0292284-0.103345im       0.132612+0.101885im    -0.038501+0.114114im      0.0513777-0.195881im       0.14183+0.215377im     -0.0870758+0.145147im     0.0321636-0.102227im     -0.0384547-0.0190458im    0.0326327+0.108336im      0.0928759+0.109497im      0.0818385+0.0305262im     0.0466741+0.0516838im    -0.353328+0.0411901im     0.0159984+0.069305im     -0.0147877-0.110369im     0.0463471+0.0509789im     0.149174-0.184985im         0.14003-0.118651im     0.0585415-0.0734688im      -0.0134233-0.229883im      0.253145+0.028887im       0.154189+0.291224im      -0.0930001+0.157033im
    0.139687+0.201301im     0.151242+0.0344236im    0.00282789+0.140523im      -0.0446027+0.0523839im     -0.280315-0.0468169im     -0.0987959-0.153196im      0.0321854-0.13638im      -0.0442474+0.107654im     -0.170274-0.155626im    -0.00383544+0.127256im     -0.0229939-0.01393im     -0.104986-0.104276im       0.206867+0.021494im      0.284642+0.0646731im     -0.234441+0.0224407im    -0.064994+0.0677431im     -0.155916+0.061127im     -0.094766-0.138534im      0.0704713-0.219469im     -0.0545485-0.0715787im      0.165845+0.04948im       -0.19961+0.079626im      0.0908187+0.213567im      0.0816298-0.0400581im     0.285716+0.0360476im   -0.0592624+0.0418791im     -0.0787878+0.0337862im   -0.0488993+0.0671929im         0.11426+0.0682135im     0.118013-0.242202im       0.038278+0.0228388im     0.00363343-0.0948287im
  -0.0688061-0.193343im     0.162231+0.0597362im     -0.117882-0.0463326im     -0.0992991-0.014341im       -0.12189-0.0973108im     -0.0790624-0.178341im     -0.0988489-0.127534im      0.0415233+0.110244im      0.153342-0.0713257im     0.0083071-0.208033im      0.0421655-0.131934im    0.0436758-0.11305im       0.0600473-0.131428im     0.0834043+0.0912769im    -0.0294607-0.117622im      0.227939-0.0319296im    -0.0326452+0.00342559im  -0.0426449+0.124866im      0.0157773-0.133792im     -0.0981872+0.0421604im      0.101585-0.217119im      0.180581+0.206543im    -0.00273159-0.212022im       0.153215+0.15918im      -0.233201-0.0908311im    -0.088407+0.0772636im    -0.00888449-0.225025im      0.014678+0.0638599im      -0.0575702+0.16115im       0.212881+0.0608964im     0.0790809+0.118154im       -0.282141-0.0762339im
   -0.146354+0.324394im    0.0150289+0.0976275im     0.0498651-0.184649im      -0.0806635-0.0345557im    -0.0779994+0.0324369im     -0.0105486-0.0828352im     -0.162077-0.018468im     -0.0399683-0.12522im       0.226728+0.167644im      -0.127592-0.00490675im     0.230248+0.0551057im  -0.0939401-0.0620965im     0.0305902+0.0865181im     0.196356-0.158873im      0.0548329-0.173024im    -0.0962735-0.0619454im      0.197951+0.23669im     0.00617794+0.0931826im    -0.0533701-0.0509256im      0.131162-0.112827im      0.0360465+0.205499im     0.0278216+0.0916227im      0.136817+0.0955773im      0.259509-0.0109899im    -0.135258-0.103326im     -0.110553-0.000916239im    0.0238227-0.0144162im   -0.0801381+0.0938051im       0.0365364-0.246858im     -0.041127+0.0611963im     -0.100082+0.108693im       0.0206574+0.209814im
    -0.16825-0.158559im     -0.13379-0.0240963im    -0.0346769-0.177488im       0.0990874-0.0295784im     -0.123293-0.132656im       -0.163955-0.0502192im      0.218443-0.120763im      -0.210171-0.0538916im   -0.0658351+0.17584im       -0.114647+0.177789im      -0.151515-0.052642im    -0.105222-0.00233497im    0.0892945-0.183435im     -0.143659-0.0307973im    -0.0438388-0.0433619im      0.14692-0.151021im       0.108815+0.01283im       0.249943-0.0715947im    -0.0260407+0.147397im       0.199169-0.111137im       0.259739-0.209971im     0.0100995-0.106645im       0.243189+0.128043im     -0.0363909+0.0737604im    0.0831395-0.101457im     0.0440916-0.0234992im      -0.200501-0.105173im    -0.0820543-0.0456474im       0.0187946+0.11476im     -0.0480646-0.0425132im     -0.037773+0.0905676im      0.0607229+0.121599im
  -0.0020087-0.209916im    0.0238183-0.118432im    -0.00815204+0.000204697im    -0.147182-0.0214893im    -0.0834452+0.107711im       0.0283664-0.0299007im     0.0661572-0.0920334im     -0.160006+0.0177916im    -0.151426-0.0681383im     -0.126942-0.473614im       0.139525+0.0685929im   -0.157299-0.0311033im     -0.127597+0.0559834im   0.00674553-0.0691316im    -0.0901808-0.0299781im   -0.0152872-0.0529843im      0.213206+0.0118805im   -0.0813792+0.0596994im     0.0684091+0.0245898im    -0.0350308-0.161017im      -0.267125+0.0358863im    -0.140141-0.155487im       0.102055-0.0756391im     -0.116267+0.0237511im     0.192596+0.0347004im    -0.244782+0.0160946im      -0.108262-0.104295im     0.0982747+0.194149im        -0.181494+0.0859224im   -0.0755144-0.0769259im     -0.184664+0.0623574im       0.111282-0.0168938im
  -0.0147868+0.0347536im   -0.103619-0.0317344im     0.0409289-0.095586im      -0.0685156-0.227858im     -0.0361122-0.0564561im      -0.222025-0.0195025im     0.0047828+0.0306326im     -0.267313-0.105758im    -0.0396917-0.174432im    0.000189561-0.105034im     0.00979616+0.0211071im   -0.182843+0.0135293im     -0.153417+0.271655im     0.0672781-0.0898911im     0.0368803-0.0831478im    0.0861603+0.142643im     -0.0961625-0.16405im      -0.118864-0.067548im      0.0231837+0.229902im     -0.0722254+0.157669im    -0.00238369-0.0424375im   -0.0551239+0.0902213im    -0.0677702+0.18118im       0.0403148-0.107822im    -0.0460854-0.251331im      0.210341-0.101696im       -0.254472+0.121677im     0.0207843+0.11386im        -0.0980476-0.0887515im  -0.00141208+0.123676im       0.224919-0.0652622im       -0.23043-0.0540146im
    0.113174+0.0715381im   -0.105582-0.125465im      -0.216094-0.0320498im       0.115592-0.202419im       0.140347-0.0939795im     0.00819909-0.0474045im      0.338968-0.029603im    -0.00570037-0.186519im    -0.0130475-0.076161im      -0.188755+0.0993977im      0.107855+0.175227im    0.0954763-0.120137im     -0.0990953-0.0321076im   -0.0533495-0.0472833im     -0.300862+0.17099im      0.0627784-0.213085im      -0.268125+0.0689199im   -0.0320914+0.0227839im     0.0265199-0.0669209im     -0.215516-0.0863676im    -0.0270403+0.127383im      0.185366+0.0553003im      0.123364-0.0902743im     0.0289756+0.103977im     -0.118763+0.0515775im   -0.0626178-0.0349421im      0.0517468+0.0537713im    0.0647607+0.0858638im      -0.0110509-0.16687im      -0.187815-0.0905982im     0.0266375+0.101406im       -0.142618-0.0280399im
    0.060755+0.115763im    -0.019119-0.0147878im     0.0947694-0.0377928im      -0.140977-0.143377im      -0.162787+0.0588163im       0.104807+0.207358im      0.0524087-0.0654734im     0.0757423+0.0800462im     0.270082-0.145687im      0.0035293-0.138226im      -0.195285-0.127319im     -0.24006-0.112998im     -0.0455872-0.129513im     -0.144285-0.00125585im   -0.0579991-0.0384308im     0.106427+0.0702357im     -0.191805+0.0330183im     0.113794-0.165836im      -0.100386+0.233646im      0.0417392+0.075512im      0.0594184+0.25199im     -0.0824479+0.131644im     -0.0108355-0.0776688im     0.0687906+0.128533im     0.0730325-0.0723333im    -0.103181-0.071011im        0.165222-0.178196im      0.293243-0.07322im          0.147891+0.0657304im    -0.142631-0.060737im      0.0612918-0.0801289im       0.090259+0.123896im
   0.0497213-0.069027im     0.132649+0.108438im      -0.120432-0.0270506im      -0.281803+0.121025im       0.173317-0.101727im       0.0558037+0.255991im       0.129056+0.122433im      -0.146913+0.0387772im   -0.0227139+0.13795im      0.00493788+0.0833077im    -0.0537914+0.122648im     0.161974-0.0960052im     -0.221048+0.0376497im   0.00207861-0.228994im      -0.054253-0.130511im     0.0604942-0.0328681im    -0.0368119+0.158057im     0.0659967-0.0443268im   0.000801268-0.0265054im     0.0779653+0.0957863im    -0.0071528+0.0425686im   -0.0190131-0.0389523im     0.0130175-0.0967314im    -0.0363024-0.223358im      0.244638-0.141698im     -0.154422+0.191928im       0.0207607-0.0999668im    -0.100044+0.128223im         0.292949+0.0390857im     0.152355+0.12491im        0.220545+0.0702839im     -0.0889438-0.0691815im
    0.112159+0.0433094im  -0.0273183+0.216423im       0.203161+0.0982339im     -0.0854365+0.114632im        0.14621+0.119087im        0.117868+0.154324im    -4.63334e-5+0.124289im     0.00823798-0.132067im     0.0628719+0.161797im      0.0200664+0.0435118im    -0.0669953-0.0557143im   0.0486553-0.248172im      -0.148965-0.0704416im   -0.0269909+0.14706im      -0.0116276+0.0245603im     0.204241+0.00406135im    0.0955197+0.0926761im    -0.237212+0.0335388im     0.0547838-0.0686544im     -0.159253-0.29551im        0.139342+6.40033e-5im   0.0271772-0.0622421im     0.0441607+0.136539im       0.104165+0.118073im     0.0567772+0.0555081im     0.162922-0.0449986im      -0.278564+0.123667im      0.279931+0.0833925im       -0.112542+0.18752im      0.0501655+0.0563858im     0.0209135+0.000222174im   -0.0768639+0.162915im
    0.122869-0.0556571im   0.0242714+0.0205449im     0.0277787+0.0524293im     -0.0748103+0.173998im     -0.0661066-0.278666im       -0.196682-0.0258461im   -0.00973199-0.00164717im     0.155266-0.12839im      -0.181499+0.324221im      -0.123232-0.0995883im     -0.123927+0.081873im     -0.16754-0.113774im       0.100999-0.0280941im     0.179523-0.0699765im    -0.0124989+0.0426017im     0.139939+0.0500566im     0.0336688-0.0645052im   -0.0212432-0.182057im      0.0812441+0.0476151im     -0.143309-0.0288534im    -0.0936793+0.115941im     0.0638442-0.007218im     -0.0693931-0.125035im     -0.0160207+0.0885626im    -0.210493+0.0449157im     0.040482-0.150223im       0.0406861-0.0527696im   -0.0573384+0.0494574im      0.00134654-0.10017im      0.0309912+0.146972im       0.263814-0.0509233im       0.412667-0.033324im
   -0.163172-0.0471559im   -0.244846+0.0977362im    -0.0336331+0.100644im     -0.00309929-0.0251294im     0.0354563-0.0250927im      0.0121998+0.00537011im     0.156656+0.204937im       0.115743+0.0675783im   -0.0258333-0.07718im       0.0282197+0.0697241im     -0.044576-0.149146im    -0.144644-0.150062im        0.11121-0.131344im     -0.154854+0.0664779im    -0.0845241-0.0111286im   -0.0310389+0.00831151im    -0.111526-0.0161404im    -0.348836+0.267164im      -0.220908-0.0143955im    -0.0677494+0.0584192im     -0.119059-0.0124892im    -0.270511+0.00490235im     0.154682+0.0331647im      0.107346-0.132493im     -0.134917-0.0600614im    -0.202726+0.118592im       -0.156429-0.124428im     -0.251506-0.0138986im    -0.000113717-0.0890532im    0.0212591+0.137357im      0.0262686-0.141839im        0.151805+0.032012im

and then generate the state $ψ$

psi = P[:, 3]
32-element Vector{ComplexF64}:
    -0.141437332336462 + 0.011154321788930856im
 -0.054377211482265625 + 0.21162603470505725im
  0.010571763285835489 - 0.06014388336633693im
    0.0401475357124827 + 0.044152154893680275im
   0.09285057516658461 - 0.2382329592088282im
   0.15748455004860443 + 0.01665105793333199im
  0.021645308617679656 - 0.0853638395170222im
   0.12581724617444673 - 0.02862650680233552im
  0.029548798098058594 - 0.07723615469018255im
  -0.16470596808631888 - 0.04586935887318127im
  0.004643689307276384 - 0.15613083766061517im
   0.14441367242606945 - 0.09831464139929849im
    0.2464689120434892 + 0.061301802642849054im
  -0.09234364085710273 - 0.24098776232709315im
 -0.015070018481028132 + 0.009759301268059592im
 -0.054310045051547275 + 0.0893328678809579im
    0.0159509121289035 - 0.033785794848611446im
  -0.09012242069388986 - 0.09302466167233088im
  0.013683127360612965 - 0.08488118348447062im
   0.23316782541318856 + 0.22818617486649972im
   0.15044867205838705 - 0.09925481999259551im
  0.026813844070405043 + 0.11011458429617065im
  -0.02811563204476294 + 0.08276187278004389im
  0.053815076343763514 - 0.006868232807169073im
  -0.14588129326507557 - 0.02985751371281405im
 -0.013853576623992562 - 0.33165192377057495im
   0.17682427267199013 + 0.0408575841728246im
  -0.09479009969173095 - 0.19002015962450178im
  -0.09424809481820043 - 0.020140336862973014im
   0.33556830182755687 + 0.0im
  -0.04987219382623538 - 0.19832444079610534im
  -0.09930110638941039 + 0.06894676616093619im

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.