##// END OF EJS Templates
Updating notebook examples, and notebook js/html.
Updating notebook examples, and notebook js/html.

File last commit:

r4330:264b061c
r4330:264b061c
Show More
qft.ipynb
1 line | 1.7 KiB | text/plain | TextLexer

Quantum Fourier Transform

In [1]:
%load_ext sympy_printing
In [2]:
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 Gate and Circuit

Build a 3 qubit QFT and decompose it into primitive gates.

In [3]:
fourier = QFT(0,3).decompose(); fourier
In [4]:
circuit_plot(fourier, nqubits=3)

The QFT circuit can be represented in various symbolic forms.

In [5]:
m = represent(fourier, nqubits=3)
In [6]:
m
In [7]:
represent(Fourier(0,3), nqubits=3)*4/sqrt(2)

QFT in Action

Build a 3 qubit state to take the QFT of.

In [8]:
state = (Qubit('000') + Qubit('010') + Qubit('100') + Qubit('110'))/sqrt(4); state

Perform the QFT.

In [9]:
qapply(fourier*state)
In [23]:
%notebook save qft.ipynb
In [207]:
%notebook load qerror.ipynb