Quantum Fourier Transform
%load_ext sympyprinting
from sympy import sqrt, symbols, Rational
from sympy import expand, Eq, Symbol, simplify, exp, sin
from sympy.physics.quantum import *
from sympy.physics.quantum.qubit import *
from sympy.physics.quantum.gate import *
from sympy.physics.quantum.grover import *
from sympy.physics.quantum.qft import QFT, IQFT, Fourier
from sympy.physics.quantum.circuitplot import circuit_plot
QFT is useful for a quantum algorithm for factoring numbers which is exponentially faster than what is thought to be possible on a classical machine.
The transform does a DFT on the state of a quantum system
There is a simple decomposition of the QFT in terms of a few elementary gates.
QFT Gate and Circuit
Build a 3 qubit QFT and decompose it into primitive gates.
fourier = QFT(0,3).decompose(); fourier
circuit_plot(fourier, nqubits=3)
The QFT circuit can be represented in various symbolic forms.
m = represent(fourier, nqubits=3)
m
represent(Fourier(0,3), nqubits=3)*4/sqrt(2)
QFT in Action
Build a 3 qubit state to take the QFT of.
state = (Qubit('000') + Qubit('010') + Qubit('100') + Qubit('110'))/sqrt(4); state
Perform the QFT.
qapply(fourier*state)