This is an example of the
qiskit.circuit.library.QFT
implementation of the Quantum Fourier transform function which is documented at: docs.quantum.ibm.com/api/qiskit/0.44/qiskit.circuit.library.QFTOutput:So this also serves as a more interesting example of quantum compilation, mapping the
init: [1, 0, 0, 0, 0, 0, 0, 0]
qc
┌──────────────────────────────┐┌──────┐
q_0: ┤0 ├┤0 ├
│ ││ │
q_1: ┤1 Initialize(1,0,0,0,0,0,0,0) ├┤1 QFT ├
│ ││ │
q_2: ┤2 ├┤2 ├
└──────────────────────────────┘└──────┘
transpiled qc
┌──────────────────────────────┐ ┌───┐
q_0: ┤0 ├────────────────────■────────■───────┤ H ├─X─
│ │ ┌───┐ │ │P(π/2) └───┘ │
q_1: ┤1 Initialize(1,0,0,0,0,0,0,0) ├──────■───────┤ H ├─┼────────■─────────────┼─
│ │┌───┐ │P(π/2) └───┘ │P(π/4) │
q_2: ┤2 ├┤ H ├─■─────────────■──────────────────────X─
└──────────────────────────────┘└───┘
Statevector([0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j,
0.35355339+0.j, 0.35355339+0.j, 0.35355339+0.j,
0.35355339+0.j, 0.35355339+0.j],
dims=(2, 2, 2))
init: [0.0, 0.35355339059327373, 0.5, 0.3535533905932738, 6.123233995736766e-17, -0.35355339059327373, -0.5, -0.35355339059327384]
Statevector([ 7.71600526e-17+5.22650714e-17j,
1.86749130e-16+7.07106781e-01j,
-6.10667421e-18+6.10667421e-18j,
1.13711443e-16-1.11022302e-16j,
2.16489014e-17-8.96726857e-18j,
-5.68557215e-17-1.11022302e-16j,
-6.10667421e-18-4.94044770e-17j,
-3.30200457e-16-7.07106781e-01j],
dims=(2, 2, 2))
QFT
gate to Qiskit Aer primitives.If we don't
transpile
in this example, then running blows up with:qiskit_aer.aererror.AerError: 'unknown instruction: QFT'
The second input is:and the output of that approximately:which can be defined simply as the normalized DFT of the input quantum state vector.
[0, 1j/sqrt(2), 0, 0, 0, 0, 0, 1j/sqrt(2)]
From this we see that the Quantum Fourier transform is equivalent to a direct discrete Fourier transform on the quantum state vector, related: physics.stackexchange.com/questions/110073/how-to-derive-quantum-fourier-transform-from-discrete-fourier-transform-dft
Course plan:
- Section "Programmer's model of quantum computers"
- look at a Qiskit hello world
- e.g. ours: qiskit/hello.py
- learn about quantum circuits.
- tensor product in quantum computing
- First we learn some quantum logic gates. This shows an alternative, and extremely important view of a quantum computer besides a matrix multiplication: as a circuit. Fundamental subsections:
- quantum algorithms