Module Expr Str ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias alias alias FunctionDef arguments args NameParam defaults body For NameStore Call NameLoad BinOpPow Num AttributeLoad NameLoad attr body Print BinOpMod Str TupleLoad NameLoad AttributeLoad NameLoad attr Expr Call NameLoad Call NameLoad BinOpMult NameLoad Call NameLoad NameLoad AttributeLoad NameLoad attr Expr Call NameLoad BinOpMult NameLoad Call NameLoad NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Return IfExp CompareEq NameLoad Call NameLoad Num AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Print TupleLoad Print Str Print Str Print Str Print Str Print TupleLoad Assign NameStore Num Print TupleLoad Str NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Print BinOpMod Str NameLoad Print TupleLoad Assign NameStore Call NameLoad NameLoad Print Str Expr Call NameLoad NameLoad Expr Call NameLoad NameLoad Print Str Expr Call NameLoad Call NameLoad BinOpMult NameLoad NameLoad Print TupleLoad Assign NameStore Call NameLoad NameLoad Print BinOpMod Str NameLoad Print Str Print Str Expr Call NameLoad Call NameLoad BinOpMult BinOpMult NameLoad NameLoad NameLoad Print TupleLoad Assign NameStore Num Print Str Print Str Assign NameStore Call NameLoad NameLoad Print Str Expr Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Print BinOpMod Str NameLoad Print TupleLoad Print Str Assign NameStore Call NameLoad Call NameLoad NameLoad NameLoad Expr Call NameLoad NameLoad Print TupleLoad Print Str Assign NameStore Call NameLoad Call NameLoad NameLoad NameLoad Expr Call NameLoad NameLoad Print TupleLoad decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A Grover's quantum search algorithm example. sympy pprint sympy.physics.quantum qapply sympy.physics.quantum.qubit IntQubit sympy.physics.quantum.grover OracleGate superposition_basis WGate grover_iteration demo_vgate_app N/A N/A v N/A N/A N/A i N/A range N/A 2 N/A v nqubits N/A N/A N/A qapply(v*IntQubit(%i, %r)) N/A i N/A v nqubits N/A N/A pprint N/A qapply N/A v N/A IntQubit i N/A v nqubits N/A N/A qapply N/A v N/A IntQubit i N/A v nqubits N/A black_box N/A N/A qubits N/A N/A N/A N/A N/A qubits N/A IntQubit 1 N/A qubits nqubits True False N/A main N/A N/A N/A N/A N/A N/A N/A Demonstration of Grover's Algorithm N/A The OracleGate or V Gate carries the unknown function f(x) N/A > V|x> = ((-1)^f(x))|x> where f(x) = 1 when x = a (True in our case) N/A > and 0 (False in our case) otherwise N/A N/A N/A nqubits 2 N/A N/A nqubits =  nqubits N/A v N/A OracleGate nqubits black_box N/A N/A Oracle or v = OracleGate(%r, black_box) nqubits N/A N/A N/A psi N/A superposition_basis nqubits N/A psi: N/A N/A pprint psi N/A N/A demo_vgate_app v N/A qapply(v*psi) N/A N/A pprint N/A qapply N/A v psi N/A N/A N/A w N/A WGate nqubits N/A N/A WGate or w = WGate(%r) nqubits N/A On a 2 Qubit system like psi, 1 iteration is enough to yield |1> N/A qapply(w*v*psi) N/A N/A pprint N/A qapply N/A N/A w v psi N/A N/A N/A nqubits 3 N/A On a 3 Qubit system, it requires 2 iterations to achieve N/A |1> with high enough probability N/A psi N/A superposition_basis nqubits N/A psi: N/A N/A pprint psi N/A v N/A OracleGate nqubits black_box N/A N/A Oracle or v = OracleGate(%r, black_box) nqubits N/A N/A N/A iter1 = grover.grover_iteration(psi, v) N/A iter1 N/A qapply N/A grover_iteration psi v N/A N/A pprint iter1 N/A N/A N/A iter2 = grover.grover_iteration(iter1, v) N/A iter2 N/A qapply N/A grover_iteration iter1 v N/A N/A pprint iter2 N/A N/A N/A N/A N/A __name__ __main__ N/A N/A N/A main