##// END OF EJS Templates
Adding new notebook examples....
Adding new notebook examples. * Many that use sympy's quantum computing (github master required) * One from Fernando Perez that does text analysis.

File last commit:

r4328:7877585c
r4328:7877585c
Show More
grovers.ipynb
1 line | 1.3 KiB | text/plain | TextLexer

Grover's Algorithm

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
In [4]:
nqubits = 3
In [3]:
def black_box(qubits):
    return True if qubits == IntQubit(1, qubits.nqubits) else False
In [5]:
psi = superposition_basis(nqubits); psi
In [6]:
v = OracleGate(nqubits, black_box)
In [7]:
iter1 = qapply(grover_iteration(psi, v)); iter1
In [8]:
iter2 = qapply(grover_iteration(iter1, v)); iter2
In [12]:
measure_all_oneshot(iter2)
In [28]:
%notebook save grovers.ipynb