Table Of ContentAn improved formalism for the Grover search algorithm
James M. Chappell*a,b, M. A. Loheb, Lorenz von Smekalc, Azhar Iqbala and Derek Abbotta
aSchool of Electrical and Electronic Engineering,
University of Adelaide 5005, Australia
bSchool of Chemistry and Physics, University of Adelaide, South Australia 5005, Australia
c Institut fu¨r Kernphysik, Technische Universit¨at Darmstadt,
2
1
0 Schlossgartenstraße 9, 64289 Darmstadt, Germany
2
∗Email: [email protected]
n
a
J Abstract
9
TheGrover search algorithm is one of the two key algorithms in the field of quantum computing,
]
h
p andhenceitisofsignificantinteresttodescribeitinthemostefficientmathematicalformalism. We
-
t show firstly, that Clifford’s formalism of geometric algebra, provides a significantly more efficient
n
a
u representation than the conventional Bra-ket notation, and secondly, that the basis defined by the
q
[ states of maximum and minimum weight in the Grover search space, allows a simple visualization
1
of the Grover search as the precession of a spin-1 particle. Using this formalism we efficiently solve
v 2
7
0 the exact search problem, as well as easily representing more general search situations.
7
1
.
1
0
2
1
:
v
i
X
r
a
1
I. INTRODUCTION
The Grover search algorithm [1–3], seeks to evolve a wave function, from some starting
state σ , into the solution state m , representing the set of all solutions, which upon
| i | i
measurement, will yield one element from this set [4–6]. In order to analyze this evolution,
typically an orthonormal basis m and m⊥ is defined, as shown on Fig (1) upon which
| i | i
the starting state σ is plotted. However in this paper we use an alternative basis, the
| i
states of maximum and minimum weight, which allows the initial sate σ and the solution
| i
state m to be symmetrically positioned in this space, allowing the conceptualizing of the
| i
Grover search process, analogous to the precession of a spin-1 particle in a magnetic field,
2
precessing in this case, from the direction of the initial state σ to the solution state m
| i | i
[7]. This approach is similar to an SO(3) picture which has previously been developed [8],
which also plots the path of the state vector during the application of the Grover operator.
Clifford algebra has also been applied previously to Grover’s algorithm [9–11], however the
approach adopted here combines the benefits of an efficient representation as well as an
integral geometric visualization.
A. The standard Grover search
Given a search space of N elements, with M of these elements being solutions to a search
query as defined by an oracle f(x), where by definition, f(x) = 1 if x is a solution, and
f(x) = 0 if x is not a solution, we set up two equivalence classes defined by the following
two states:
1
m = x , (1)
| i √M | i
x∈M
X
1
m⊥ = x ,
| i √N M | i
− x∈/M
X
allowing us to define a uniform superposition starting state in terms of these two states as
N−1
1 N M M
σ = x = − m⊥ + m . (2)
| i √N | i N | i N | i
r r
x=0
X
Grover’ssolutiontothesearch process[4], involves iteratively applying aunitaryoperator
G defined by
G = G G = (I 2 σ σ )(I 2 m m ). (3)
σ m
− − − | ih | − | ih |
2
m
✻| i
✘✘✘✘✘✘✘θ2✘✘1✘✘✘✘✘✘✘✿α✲|σ=i qMN
m⊥
β = √1 α2 | i
−
FIG. 1: Geometry of starting state σ .
| i
This operator applied to the n = logN qubits representing the search space, rotates the
⌈ ⌉
state vector an angle given by
θ M
sin = (4)
2 N
r
at each application, and after
π N
R (5)
≤ 4 M
& r '
iterations, the wave function will lie close to the solution state m .
| i
B. Modified basis vectors for the search space
The Grover search space, is found to be isomorphic to an su(2) space [12], and using
the states of maximum and minimum weight, we can find a geometric picture of the search
process, in a real three-dimensional space. Working fromthetwo-dimensional complex space
shown in Fig (1), using the well defined states m and σ , we have four possible operators:
| i | i
m σ , σ m , m m and σ σ . From these we define:
| ih | | ih | | ih | | ih |
β2
K = P (6)
− 2
P σ σ m m
J = −| ih |−| ih | (7)
1
2 α
| |
i(α∗ m σ α σ m )
J = − | ih |− | ih | (8)
2
2 α β
| |
σ σ m m
J = | ih |−| ih |,
3
2β
3
where α = σ m , which may be complex, β = 1 α 2, and i = √ 1 with
h | i −| | −
( σ σ pm m )2
P = | ih |−| ih | . (9)
β2
We then find
[J ,J ] = iǫ J (10)
i j ijk k
P
[J ,J ] = δ
i j + ij 2
[K,J ] = 0,
i
where δ is the Kronecker delta symbol, and ǫ is the Levi-Civita symbol, confirming we have
an su(2) algebra. Squaring the generators we find
1 1
J2 = J2 = J2 = ( σ σ m m )2 = P. (11)
1 2 3 4β2 | ih |−| ih | 4
We can easily check, P σ = σ and P m = m , with P2 = P and the Casimir invariant
| i | i | i | i
3
C = J2 +J2 +J2 = P,
1 2 3 4
which corresponds to a spin 1 system. We have the raising and lowering operators
2
J = J iJ
± 1 2
±
and requiring J = 0 and J = 0, we find the states of highest and lowest weight
+ −
| ↑i | ↓i
θ θ θ
= sec sin m eiδcos σ (12)
| ↑i 2 4| i− 4| i
(cid:18) (cid:19)
θ θ θ
= sec cos m eiδsin σ ,
| ↓i 2 4| i− 4| i
(cid:18) (cid:19)
where sin θ = α and α = α eiδ. We then find J = +1 and J = 1 , as
2 | | | | 3| ↑i 2| ↑i 3| ↓i −2| ↓i
expected for a spin 1 system. Writing σ and m in this new basis we obtain
−2 | i | i
θ θ
σ = e−iδ cos +sin (13)
| i − 4| ↑i 4| ↓i
(cid:18) (cid:19)
θ θ
m = sin +cos
| i − 4| ↑i 4| ↓i
θ θ
m⊥ = cos +sin .
| i 4| ↑i 4| ↓i
Using these results, we can substitute back into the Grover iteration Eq. (3) to find
θ θ
G = I +2cos2 +sinθ sinθ +2cos2 , (14)
− 2| ↑ih↑ | | ↑ih↓ |− | ↓ih↑ | 2| ↓ih↓ |
4
which can be immediately written in matrix form as
cosθ sinθ
G = , (15)
sinθ cosθ
−
which shows as expected, that the Grover operation rotates the state vector by an angle θ,
where the starting state will be for this basis
cos θ
σ = e−iδ − 4 . (16)
| i sin θ
4
C. Clifford’s algebra of three-space
Using the orthonormal basis , , defined in Eq. (12), we now model the search
| ↑i | ↓i
process using the real associative algebra of GA. We define unit algebraic elements e ,e ,e ,
1 2 3
such that e2 = e2 = e2 = 1, and for distinct i and j we have the anticommutation rule
1 2 3
e e = e e [13]. The algebraic elements e ,e ,e , define a three-dimensional space, and so
i j j i 1 2 3
−
we can define two vectors a = a e +a e +a e and b = b e +b e +b e , then using the
1 1 2 2 3 3 1 1 2 2 3 3
distributive law of multiplication over addition we find
ab = (a e +a e +a e )(b e +b e +b e ) (17)
1 1 2 2 3 3 1 1 2 2 3 3
= a b +a b +a b +(a b b a )e e +(a b a b )e e +(a b b a )e e
1 1 2 2 3 3 2 3 2 3 2 3 1 3 3 1 1 3 1 2 1 2 1 2
− − −
= a b+ιa b = a b+a b,
· × · ∧
where a b is therefore the conventional dot or inner product and a b is the wedge or outer
· ∧
product. In three dimensions we have the relationship with the conventional vector product
that a b = ιa b, where we have defined the trivector ι = e e e , which represents a
1 2 3
∧ − ×
signed unit volume.
Using the product defined Eq. (17), with orthonormal basis elements, we find
e e = e .e +e e = δ +ιǫ e , (18)
i j i j i j ij ijk k
∧
indicating that we have an isomorphism between the basis vectors e ,e ,e and the Pauli
1 2 3
matrices through the use of the geometric product. We find that ι2 = e e e e e e = 1
1 2 3 1 2 3
−
and we also find that ι commutes with all other elements of the algebra and so can be used
in place of the unit imaginary i = √ 1. The bivectors also square to negative one, that is
−
(e e )2 = (e e )(e e ) = e e e e = 1, which are used to define rotations in the plane of
i j i j i j i j j i
− −
the bivector.
5
1. Rotations in 3-space with geometric algebra
The Grover search process involves the incremental rotation of the state vector and, in
geometric algebra, in order to rotate a vector by an angle a about an axis given by the
| |
vector a we define a rotor
a
R = e−ιa/2 = cos( a /2) ι sin( a /2), (19)
| | − a | |
| |
which acts by conjugation to rotate vector v = v e +v e +v e , using
1 1 2 2 2 3
v′ = RvR† = e−ιa/2veιa/2. (20)
The is also called the reversion operation, which flips the order of the terms and switches
†
the sign of ι. The bilinear transformation used to calculate rotations is preferred, because
it applies completely generally, to not only rotating vectors, but also any components of the
algebra, and also in any number of dimensions.
2. Representing quantum states in Geometric Algebra(GA)
We can identify a simple 1:1 mapping from complex spinors to the bivectors of GA as
follows [13–15]
a +ia
0 3
ψ = z +z = ψ = a +a ιe . (21)
1 2 0 k k
| i | ↑i | ↓i ↔
a +ia
2 1
−
This maps spinors to the even sub subalgebra of GA, which is closed under multiplication.
Converting the complex spinors defined in Eq. (13), we find using Eq. (21)
θ θ
σ cos sin ιe = eιe2θ/4 (22)
2
| i 7→ − 4 − 4 −
θ θ
m sin cos ιe = eιe2(π/2−θ/4) = ιe e−ιe2θ/4
2 2
| i 7→ − 4 − 4 − −
θ θ
m ⊥ cos sin ιe = e−ιe2θ/4.
2
| i 7→ 4 − 4
We can now transform GA type spinors into a real space representation through the trans-
formation
S = ψe ψ†, (23)
3
6
which gives us the three-space vectors
θ θ
σ = eιe2θ/4e e−ιe2θ/4 = eιe2θ/2e = sin e +cos e (24)
3 1 1 3
− 2 2
θ θ
m = eιe2(π/2−θ/4)e e−ιe2(π/2−θ/4) = e eιe2θ/2 = eιe2(π−θ/2)e = sin e cos e
3 3 3 1 3
− − 2 − 2
θ θ
m⊥ = e−ιe2θ/4e eιe2θ/4 = e eιe2θ/2 = sin e +cos e .
3 3 1 3
2 2
Hence the vectors σ, m and m⊥, can now be plotted in a real Cartesian space analogous to
the Bloch sphere representation as shown in Fig (2), and can be compared with [8]. As can
be seen we use the e (z-axis) from which to measure the angle θ, and φ is measured from
3
e .
1
σ e3 m⊥ Gmσ
❈❖ ✻ ✄✗
❈ ✄
✡✣
❈ ✄ ✡
❈ ✄ ✡
❈ ✄ ✡
❈ ✄ ✡
❈ ✄ ✡
❈ ✄ ✡
❈ ✄ ✡ e
θ θ 2
❈ 2 2✄θ ✡ ✟✟✯
✟
❈ ✄ ✡ ✟
✟
❈ ✄✡ ✟
✟
✟✟❈✄✡✄✟ ✟✟ ✲ e1
✟
✟ ✄
✟
✟ ✄
✟✟
✄
✄
✄
✄
✄
✄
✄
✄
✄
✄✎
m
FIG. 2: Grover search in three-space based on states of maximum and minimum weight. The two
possible precession axes are now e and e , in order to rotate σ onto m.
1 2
II. THE GROVER SEARCH OPERATOR IN GA
The action of the oracle G on m is (I 2 m m ) m = m , which is to flip the ‘m’
m
| i − | ih | | i −| i
coordinate about the m⊥ axis [5]. Reflections are easily handled in GA, through double
| i
7
sided multiplication of the vector representing the axis of reflection, the action of the oracle
being therefore
m⊥σm⊥ = mσm. (25)
Using the starting state defined in Eq. (24) we find the action of the oracle on the starting
state σ as
3θ 3θ
mσm = e−ιe2θ/2e e e−ιe2θ/4e−ιe2θ/2e = e−ιe23θ/2e = cos e +sin e , (26)
3 3 3 3 3 1
2 2
which is the required vector; c.f. Fig (2).
The action of the other half of the Grover operator G = I 2 σ σ also produces a
σ
− | ih |
reflection, but this time about the σ vector, which therefore implies a full Grover iteration
of the starting state will be σ(mσm)σ = (σm)σ(mσ) = GσG†, using associativity, giving
the combined Grover operator as
G = σm = eιe2θ/2e e eιe2θ/2 = eιe2θ, (27)
3 3
−
which is a significantly more compact form for the standard Grover operator, in comparison
to Eq. (3). We can see by inspection, that the Grover operator represents a rotation of 2θ
about the e axis, which will clearly rotate the vector σ onto m, after an appropriate number
2
of operations, as shown in Fig. 2. Hence, after k iterations we require the Grover operator
G to rotate the vector σ, defined in Eq. (24), onto the solution vector m, and so we require
GkσG†k = eιke2θeιe2θ/2e e−ιke2θ = eιe2(2kθ+θ/2)e = m, (28)
3 3
using eιe2θ k = eιke2θ, and with m defined in Eq. (24), we therefore require
(cid:0) (cid:1)
eιe2(2kθ+θ/2)e = eιe2(π−θ/2)e , (29)
3 3
and so by equating exponents, ignoring rotations modulo 2π, we find the condition
θ θ
2kθ+ = π , (30)
2 − 2
or
π 1
k = , (31)
2θ − 2
and using θ = 2arcsin M for a database with M solutions, we find
N
q
π 1 π N
k = , (32)
− 2 ≈ 4 M
4arcsin M r
N
q
8
the well known result for the standard Grover search. However, clearly, there is no guarantee
that the formula will return k as an integer, and because it will need to be rounded to the
nearest integer describing the number of Grover operations, then we will not always return
exactly the solution space upon measurement. However we can modify the search slightly,
in order to guarantee that k will be an integer, and hence reliably return the solution state
m .
| i
A. Exact Grover search
The Grover operator, defined in Eq. (3), can be modified so that it rotates the starting
state σ exactly onto the solution states m , thus finding a solution with certainty [12, 16].
| i | i
In order to create the exact Grover search, the Grover operator is typically generalized to
G = (I (1 eiφ1) σ σ )(I (1 eiφ2) m m ), (33)
− − − | ih | − − | ih |
so that when the oracle identifies a solution it applies a complex phase eiφ2 to the wave
function and not just the scalar 1 [12]. This has the effect of slightly slowing down the
−
search process, but it then allows the solution state m to be reached exactly using an
| i
integral number of iterations.
A reflection can be viewed as a rotation by π in one higher dimension, so if we rotate by
an angle φ about the m axis, which will be clockwise as viewed from above the e axis, we
2 3
obtain the oracle
G = eιφ22(sin(θ/2)e1+cos(θ/2)e3). (34)
m
For φ = π we find G = ι(sin(θ/2)e +cos(θ/2)e ) = ιm, so that the action of the oracle
2 m 1 3
G σG† = ιmσ( ιm) = mσm, (35)
m m −
whichgivesthesameresultasthestandardGroveroraclefoundpreviouslyEq.(25), similarly
G = e−ιφ21(−sin(θ/2)e1+cos(θ/2)e3) (36)
σ
will be a rotation about the σ axis. Hence for the exact search for the Grover operator we
have
G = G G (37)
σ m
−
= e−ιφ21(−sin(θ/2)e1+cos(θ/2)e3)eιφ22(sin(θ/2)e1+cos(θ/2)e3),
−
9
which when expanded gives
φ φ φ φ φ +φ θ
1 2 1 2 1 2
G = cos cos +cosθsin sin +sin sin ιe (38)
1
2 2 2 2 2 2
φ φ θ φ φ
1 2 1 2
+sin sin sinθιe cos sin − ιe ,
2 3
2 2 − 2 2
for the general Grover operator, which is now interpreted as a rotation about a general
precession axis.
1. Phase matching
We can see from Fig. 2, which uses the alternate orthonormal basis and , that σ
| ↑i | ↓i
and m now lie in the plane of e and e , and hence using a geometric argument the Grover
1 3
precession axis must therefore lie in the plane of e and e in order for the σ vector to be able
1 2
to be rotated precisely onto the m vector. Hence we need to eliminate the e component in
3
the precession axis, and hence, by inspection of Eq. (37), we require φ = φ , which is the
1 2
well known phase matching condition [16, 17]. Hence the exact search will be in the form
G = eιβ(sinαe1+cosαe2), (39)
−
where we find
β θ φ
sin = sin sin (40)
2 2 2
θ φ
cotα = cos tan ,
2 2
which can be re-expressed assuming a normalization factor Z as
G = eιβ(cosφ2e1+cos2θsinφ2e2)/Z, (41)
which shows clearly the precession plane perpendicular to the vector cos φe +cos θ sin φe ,
2 1 2 2 2
and if we select φ = π, we recover the standard Grover search operation.
To calculate φ for the exact search we, once again have the vector equation, given by
Eq. (28), and substituting our modified Grover operator, along with Eq. (24), we find
eιkβ(sinαe1+cosαe2)eιe2θ/2e e−ιkβ(sinαe1+cosαe2) = e−ιe2θ/2e (42)
3 3
−
which can be rearranged to
eιkβ(sinαe1+cosαe2)eιe2θ/2eιkβ(sinαe1+cosαe2)eιe2θ/2 = 1 (43)
−
10