<<

EE214/PHYS220 Lecture 3: QC structure and quantum gates

Simple structure of a quantum computer (without error correction)

|0 |0 (quantum circuit diagram, |0〉 |0〉 read left-to-right) |0〉 〉 . . . |0〉 𝑈𝑈 measurement 〉 initialization Unitary operation depends on what we need (e.g., a number to factor) 𝑈𝑈 Idea: at the measurement stage some states are preferable (amplitudes of other states are 0), the result tells us what we need - We may need to measure only some ≈ - Still some randomness of the result (so mostly “hard to solve, easy to check” problems) QC structure with error correction |0 classical |0 res. meas 〉 1 〉 𝑟𝑟 meas ( ) 2 1 𝑟𝑟 ( ) |0 𝑈𝑈 . . . 𝑈𝑈2 𝑟𝑟1 meas 3 2 𝑛𝑛 Unitary〉 operations do not necessarily involve all qubits𝑈𝑈 𝑟𝑟 𝑟𝑟 Technical issue: physical qubits can be reused 𝑈𝑈𝑖𝑖 |0 |0 |0 res. meas |0 〉 〉 〉 1 ( ) 𝑟𝑟 〉 result 1 2 1 . . . |0 𝑈𝑈 𝑈𝑈 𝑟𝑟 measurement

Unitary〉 operations can be decomposed into simpler gates (usually 1-𝑟𝑟 𝑛𝑛 or 2-qubit, sometimes 3-qubit gates). 𝑖𝑖 Unitary operations𝑈𝑈 are reversible, so QC is related to reversible computing (classically permutations, often permutations in QC as well); measurement is irreversible. Language of quantum circuit diagrams (more notations later when we need them) qubit idling: thin line (“wire”) several idling qubits (Nielsen-Chuang’s book) (Mermin’s book) x result measurement (N-C book) M (Mermin) meas.

Read quantum circuit diagrams from left to right ( )

| |

|𝜓𝜓〉 𝑈𝑈 𝑈𝑈 𝜓𝜓〉 |

𝜓𝜓〉 𝑈𝑈 𝑉𝑉 𝑉𝑉𝑉𝑉 𝜓𝜓〉 So = 𝑈𝑈 𝑉𝑉 𝑉𝑉𝑉𝑉 One-qubit logic gates “gate” = “operation” = “function” = “map” = “transformation”

Classically, 4 one-bit functions: 0 0 0 1 0 0 0 1 1 1 1 0 1 0 1 1 → → → → ( 2 N-bit 1-bit functions) → NOT→ erase→ → 𝑁𝑁 2 not reversible → So, only 2 reversible 1-bit operations:𝕀𝕀 NOT (0 1) and unityerase′ operation

Quantum 1-qubit gate: any unitary 2 × 2 ↔ “Unitary” means = = (= 1) † † Actually, not U(2) 𝑈𝑈,𝑈𝑈 but𝑈𝑈𝑈𝑈 SU(2);𝕀𝕀 “special”� means det( ) = 1 overall phase is not important for a 1-qubit gate (though will be important for control𝑈𝑈 -gates) A unitary matrix has 8 4 = 4 degrees of freedom = A matrix from SU(2) has 3− degrees †of freedom, SU(2) SO(3) (3D group) 𝑈𝑈𝑈𝑈 𝕀𝕀 A qubit state: direction of , a rotation is characterized by 3 Euler (digression)

0 1 = 1 0 Pauli matrices are Hermitian and unitary 𝜎𝜎𝑋𝑋 0 = Language of Quantum Computing to a significant 0 extent is based on Pauli matrices −𝑖𝑖 𝜎𝜎𝑌𝑌 1 0 = 𝑖𝑖 Together with unity matrix , they form 0 1 an (almost) orthonornmal in the 𝕀𝕀 𝜎𝜎𝑍𝑍 space of 2 × 2 matrices − Tr = 2 1 0 = † 1 0 1 Inner product𝜎𝜎𝑖𝑖 𝜎𝜎𝑗𝑗 for matrices𝛿𝛿𝑖𝑖𝑖𝑖 is introduced as 𝕀𝕀 for vectors (matrix is “stretched” into vector): = ∗ 𝛼𝛼 𝛽𝛽 =∑𝑛𝑛 𝛼𝛼𝑛𝑛𝛽𝛽𝑛𝑛 = = Tr( ) ∗ † † 𝐴𝐴̂ 𝐵𝐵� ∑(called𝑖𝑖𝑗𝑗 𝐴𝐴𝑖𝑖𝑖𝑖𝐵𝐵 Frobenius𝑖𝑖𝑖𝑖 ∑𝑖𝑖𝑗𝑗 𝐴𝐴inner𝑗𝑗𝑖𝑖𝐵𝐵𝑖𝑖𝑖𝑖 product)𝐴𝐴 𝐵𝐵 Most important 1-qubit gates

1. Bit flip (NOT, X-gate, Pauli-X) 0 1 = = = 1 0 𝑋𝑋 𝜎𝜎𝑋𝑋 𝑁𝑁𝑁𝑁𝑁𝑁 𝑋𝑋 0 1 |0 = so 1 0 |1 𝛼𝛼 𝛽𝛽 𝛼𝛼 𝛽𝛽 〉 → 0 + 𝛽𝛽1 𝛼𝛼0 + |1 𝛽𝛽 𝛼𝛼0 = 1 〉 1 = 0 𝛼𝛼 𝛽𝛽 → 𝛽𝛽 𝛼𝛼 〉 𝑋𝑋 2. Phase flip (Z-gate) 𝑋𝑋 1 0 = = 0 1 𝑍𝑍 𝜎𝜎𝑍𝑍 𝑍𝑍 0 +− 1 0 |1 0 + 1 = 0 |1 𝛼𝛼 𝛽𝛽 → 𝛼𝛼 − 𝛽𝛽 〉 𝑍𝑍 𝛼𝛼 0 = 𝛽𝛽0 𝛼𝛼 − 𝛽𝛽 〉 1 = 1 𝛼𝛼 𝛼𝛼 → 𝑍𝑍 𝛽𝛽 −𝛽𝛽 𝑍𝑍 − Most important 1-qubit gates (cont.) 3. Phase & bit flip (Y-gate) 0 = = 0 −𝑖𝑖 0 + 1 = 0 + |1 𝑌𝑌 𝜎𝜎𝑌𝑌 𝑌𝑌 𝑖𝑖 0 = 1 1 = 0 𝑌𝑌 𝛼𝛼 = 𝛽𝛽 = −𝑖𝑖𝑖𝑖 𝑖𝑖𝑖𝑖 〉 𝛼𝛼 −𝑖𝑖𝑖𝑖 𝑌𝑌 𝑖𝑖 → Very𝛽𝛽 often defined𝑖𝑖𝑖𝑖 𝑌𝑌 0−𝑖𝑖 1 𝑌𝑌 𝑖𝑖𝑖𝑖𝑖𝑖0 −1𝑖𝑖𝑖𝑖𝑖𝑖 Mermin-web = or = differently: 1 0 1 0 (Eqs. 1.48, 1.49) − 𝑌𝑌 In Mermin-𝑌𝑌book the usual definition (Eq. 1.51), 4. Hadamard except in Ch. 5 (error− correction) 1 1 1 = + 2 1 1 2 𝐻𝐻 𝐻𝐻 𝛼𝛼 𝛽𝛽 − 𝛼𝛼 |0 + |1 0 |1 → 2 0 = 1 = 𝛽𝛽 𝛼𝛼 − 𝛽𝛽 2 2 〉 〉 − 〉 𝐻𝐻 𝐻𝐻 Most important 1-qubit gates (cont.) 5. Phase gate 1 0 1 0 = = 0 0 / 𝑆𝑆Notation from N-C book 𝑖𝑖𝑖𝑖 2 1 𝑆𝑆0 = 𝑖𝑖 since 𝑒𝑒 = Do not confuse with Mermin’s 0 notation for SWAP 𝑖𝑖𝑖𝑖 𝑆𝑆 𝑍𝑍 𝑍𝑍 𝑖𝑖𝑖𝑖 𝑒𝑒 𝑆𝑆 6. “ 8”-gate or T-gate

𝜋𝜋1⁄ 0 = 0 / Notation from N-C book 𝑖𝑖𝑖𝑖 4 𝑇𝑇 𝑇𝑇 = 𝑒𝑒 Called /8 because equivalent to exp( ) 𝑇𝑇 𝑆𝑆 𝜋𝜋 𝜋𝜋 −𝑖𝑖 8 𝑍𝑍 Sequential gates

Possible confusion: left-to-right in quantum circuit diagrams, right-to-left in matrix notations

=

Example 𝑈𝑈 𝑉𝑉 𝑉𝑉𝑉𝑉 |0

〉 𝑆𝑆 𝑍𝑍 𝐻𝐻 means 1 1 1 0 1 0 1 0 = 1 1 0 1 0 0 𝐻𝐻 𝑍𝑍 𝑆𝑆 |0 − − 𝑖𝑖 𝐻𝐻 𝑍𝑍 𝑆𝑆 〉 Summary for main 1-qubit gates

0 1 = 1 0 bit flip 1 0 𝑋𝑋 = phase flip 0 1 𝑍𝑍 0 = − phase & bit flip 0 −𝑖𝑖 𝑌𝑌 1 1 1 = 𝑖𝑖 Hadamard 2 1 1 𝐻𝐻 1 0 = =− 0 𝑆𝑆 𝑍𝑍 = 𝑖𝑖 𝑇𝑇 𝑆𝑆 Some useful relations

0 1 0 1 0 ======1 0 0 0 1 2 2 2 −𝑖𝑖 𝑋𝑋 1 1 1 𝑌𝑌 𝑍𝑍 𝑋𝑋 = 𝑌𝑌 𝑍𝑍 𝕀𝕀 = 𝑖𝑖 − 2 1 1 2 𝐻𝐻 𝐻𝐻 = 𝕀𝕀 = − = = The factor is not important (overall phase), 𝑋𝑋𝑋𝑋 −𝑌𝑌𝑌𝑌 𝑖𝑖𝑖𝑖 therefore sufficient to consider and . = = 𝑖𝑖 𝑌𝑌𝑌𝑌 −𝑍𝑍𝑍𝑍 𝑖𝑖𝑖𝑖 𝑋𝑋 𝑍𝑍 𝑍𝑍𝑍𝑍 =−𝑋𝑋𝑋𝑋, 𝑖𝑖𝑖𝑖 =

𝐻𝐻Check𝐻𝐻𝐻𝐻 𝑍𝑍 𝐻𝐻𝑍𝑍𝐻𝐻 𝑋𝑋 1 1 1 0 1 1 1 1 1 1 1 1 1 1 2 0 1 0 = = = 2 1 1 1 0 2 1 1 2 1 1 1 1 2 0 2 0 1 exchange rows − − =− − = − −

The second equation 𝑋𝑋𝑋𝑋 𝐴𝐴EXCHANGED= ⇒ ROWS 𝐴𝐴𝐴𝐴= 𝐴𝐴EXCHANGED COLUMNS 𝐻𝐻𝐻𝐻𝐻𝐻 𝑍𝑍 𝐻𝐻𝐻𝐻𝑋𝑋𝐻𝐻𝐻𝐻 𝐻𝐻𝑍𝑍𝐻𝐻 Same relations in the language of circuit diagrams

= 𝑋𝑋 𝑋𝑋 = 𝑌𝑌 𝑌𝑌 = 𝑍𝑍 𝑍𝑍 = 𝐻𝐻 𝐻𝐻 = 𝐻𝐻 𝑋𝑋 𝐻𝐻 = 𝑍𝑍 𝐻𝐻 𝑍𝑍 𝐻𝐻 𝑋𝑋 Bloch (some physical meaning) = 0 + 1 = cos 0 + sin 1 2 2 𝑖𝑖𝑖𝑖 𝜃𝜃 𝑖𝑖𝑖𝑖 𝜃𝜃 𝜓𝜓 𝛼𝛼 𝛽𝛽 irrelevant𝑒𝑒 𝑒𝑒 : zenith (polar) , 0

𝜃𝜃 : azimuth angle, mod≤2𝜃𝜃 ≤ 𝜋𝜋 (often𝜑𝜑 |0 at the bottom, |1 at 𝜋𝜋the top)

Corresponds 〉to direction of a spin〉 in real space axis → |0 0 + |1 axis → 2 𝑍𝑍 axis → |1〉 𝑖𝑖 〉 𝑌𝑌 0 |1 −𝑍𝑍 0〉 + |1 axis → plane → cos 0 ± sin |1 axis → 2 2 2 2 − 𝑖𝑖 〉 𝜃𝜃 𝜃𝜃 〉 −𝑌𝑌 0 + |1 𝑋𝑋𝑋𝑋 〉 𝑋𝑋 0 |1 → plane → cos 0 ± sin |1 equator 2 2 axis → 2𝑖𝑖𝑖𝑖 2 𝑒𝑒 〉 𝜃𝜃 𝜃𝜃 − 〉 𝑌𝑌O𝑌𝑌rthogonal vectors in Hilbert𝑖𝑖 space〉 −correspond𝑋𝑋 to opposite directions on Unitary 1-qubit transformations Physical evolution leads to a unitary transformation of wavefunctions

| = ⇒ = 0 , = ( ) 𝑖𝑖 − 𝑖𝑖⁄ℏ 𝐻𝐻�𝑡𝑡 𝜓𝜓̇ 〉 −Since𝐻𝐻� 𝜓𝜓is Hermitian,𝜓𝜓 𝑡𝑡 is unitary𝑈𝑈� 𝜓𝜓 � ℏ 𝑈𝑈 𝑒𝑒 𝐻𝐻� = ( ) 𝑈𝑈�( ) = 1 † † − 𝑖𝑖⁄ℏ 𝐻𝐻�𝑡𝑡 𝑖𝑖⁄ℏ 𝐻𝐻� 𝑡𝑡 (2)𝑈𝑈�: 𝑈𝑈group� 𝑒𝑒of unitary𝑒𝑒 transformations� in 2D 𝑈𝑈(2): of (2) with det = 1 (since overall phase in not important, means special) 𝑆𝑆𝑆𝑆 𝑈𝑈 2 (3) (special orthogonal𝑆𝑆 in 3D, group of in 3D, (almost ;𝑆𝑆𝑆𝑆 ↔ 𝑆𝑆 𝑆𝑆actually “special” means det = 1, not 1) 2 1, ±1) − → � 1-qubit unitary operations correspond to rotations of the Bloch sphere Main 1-qubit operations on the Bloch sphere 0 1 = Rotation about X-axis by angle (180°) 1 0 𝑋𝑋 (rotation counterclockwise looking𝜋𝜋 from the axis end, but not important since )

0 + |1 0 + |1 𝜋𝜋 X-axis does not move: 2 2 〉 〉 0 |1 0→ |1 Note that 2 2 − 〉 − 〉 (be careful with→ − overall phase)

Larmor rotation (precession) of a real spin by a magnetic field along X (this is a physical picture, often used in QC; = , is gyromagnetic ratio)

𝜔𝜔 𝛾𝛾𝛾𝛾 𝛾𝛾 Main 1-qubit operations on the Bloch sphere (cont.) 1 0 = 0 1 Rotation about Z-axis by (180°) 𝑍𝑍 1 0 𝜋𝜋 = − 0 1 Rotation about Y-axis by (180°) 𝑌𝑌 𝜋𝜋 1 −0 = 0 1 Rotation by about axis in XZ plane, which is at angle 4 from Z and X 𝐻𝐻 𝜋𝜋 − Now it is obvious why = = = = 1, just a rotation𝜋𝜋⁄ by 2 2 2 2 1 0 𝑋𝑋 𝑌𝑌 𝑍𝑍 𝐻𝐻 � 2𝜋𝜋 = Rotation about Z-axis by 2 (90°) 0 𝑆𝑆 1 0 𝜋𝜋⁄ = 𝑖𝑖 Rotation about Z-axis by 4 (45°) 0 𝑇𝑇 𝑖𝑖𝜋𝜋⁄4 𝜋𝜋⁄ 𝑒𝑒 Main 1-qubit operations on the Bloch sphere (cont.)

1 0 = Rotation by about axis in XZ plane, 0 1 which is at angle 4 from Z and X 𝜋𝜋 𝐻𝐻 − 𝜋𝜋⁄ Another rotation realization for Hadamard

= 2 ( )

(rotation𝐻𝐻 𝑅𝑅𝑌𝑌 about𝜋𝜋⁄ Z𝑅𝑅 by𝑍𝑍 𝜋𝜋 and rotation about Y by 2) 1 1 1 1 0 𝜋𝜋 1 1 1 𝜋𝜋⁄ Check: = 2 1 1 0 1 2 1 1 − − − |0 + |1 0 2 Counterclockwise rotation 〉 〉 → |0 + |1 about Y by 2 1 2 − 〉 〉 𝜋𝜋⁄ → Arbitrary 1-qubit unitary transformation

An arbitrary 1-qubit unitary can be parametrized as

= exp 2 𝑖𝑖𝑖𝑖 𝜃𝜃 𝑈𝑈 𝑒𝑒 −𝑖𝑖 𝑛𝑛𝜎𝜎⃗ where = + + ,

, , , 𝑛𝑛𝜎𝜎⃗, 𝑛𝑛are𝑥𝑥𝜎𝜎𝑥𝑥 real𝑛𝑛 𝑦𝑦numbers,𝜎𝜎𝑦𝑦 𝑛𝑛𝑧𝑧𝜎𝜎𝑧𝑧 + + = 1 is irrelevant (overall phase), so 3 real parameters 2 2 2 𝛼𝛼 𝜃𝜃 𝑛𝑛𝑥𝑥 𝑛𝑛𝑦𝑦 𝑛𝑛𝑧𝑧 𝑛𝑛𝑥𝑥 𝑛𝑛𝑦𝑦 𝑛𝑛𝑧𝑧 Counterclockwise rotation about axis by angle 𝛼𝛼 (this is why 2 and “ ” ) 𝑛𝑛 𝜃𝜃 Useful relation:𝜃𝜃⁄ exp − = cos 1 sin 2 2 2 𝜃𝜃 𝜃𝜃 𝜃𝜃 follows from−𝑖𝑖 𝑛𝑛𝜎𝜎⃗ = 1 � − 𝑖𝑖 𝑛𝑛𝜎𝜎⃗ 2 𝑛𝑛𝜎𝜎⃗ �

EE214/PHYS220 Quantum Computing Two-qubit states and 2-qubit gates Two-qubit states

= 00 + 01 + 10 + 11 = 00 = = = = 𝛼𝛼 01 00 01 10 11 𝛼𝛼 𝜓𝜓 𝛼𝛼 𝛼𝛼 𝛼𝛼 𝛼𝛼 𝛼𝛼10 11 𝛼𝛼+1 +𝛼𝛼2 + 𝛼𝛼3 = 1 𝛼𝛼4 𝛼𝛼 2 2 2 2 Overall𝛼𝛼00 phase𝛼𝛼01 is not important𝛼𝛼10 ⇒𝛼𝛼11can choose real

0 8 2 = 6 degrees of freedom (2 2 2 degrees𝛼𝛼 of freedom for qubits) 𝑘𝑘 − � − 𝑘𝑘 Two-qubit states

= 00 + 01 + 10 + 11 = 𝛼𝛼00 01 8 2 = 600degrees of01 freedom 10 11 𝛼𝛼 𝜓𝜓 𝛼𝛼 𝛼𝛼 𝛼𝛼 𝛼𝛼 𝛼𝛼10 11 Tensor-product− states (outer-product, direct-product): each qubit𝛼𝛼 is some state

0 + 1 0 + |1 ) =

𝛼𝛼0 𝛼𝛼1 ⊗ 𝛽𝛽0 𝛽𝛽1 〉 = 00 + 01 + 10 + 11 = 𝛼𝛼0𝛽𝛽0 𝛼𝛼0𝛽𝛽1 2 + 2 𝛼𝛼=04𝛽𝛽0degrees𝛼𝛼 of0𝛽𝛽 freedom1 𝛼𝛼 1𝛽𝛽0 𝛼𝛼1𝛽𝛽1 𝛼𝛼1𝛽𝛽0 1 1 A general 2-qubit state is a tensor-product state only if 𝛼𝛼 𝛽𝛽= . Otherwise – entanged. 𝛼𝛼00𝛼𝛼11 𝛼𝛼10𝛼𝛼01 Notations for multi-qubit computational-basis states

3 2 1 0 3 2 1 0 3 2 1 0 Computational𝑥𝑥 𝑥𝑥 𝑥𝑥 𝑥𝑥 ≡-basis𝑥𝑥 state,𝑥𝑥 𝑥𝑥 represents𝑥𝑥 ≡ 𝑥𝑥 classical⊗ 𝑥𝑥 state⊗ 𝑥𝑥 ⊗2 𝑥𝑥 𝑛𝑛 ∑𝑥𝑥𝑛𝑛 | (most significant bit at the top) | 𝑥𝑥3〉 | 𝑥𝑥2〉 | 𝑥𝑥1〉 𝑥𝑥0〉 However, people often say in opposite order: first qubit, second qubit, etc. Two-qubit gates

Any unitary 4 × 4 matrix (overall phase is not important) 𝑈𝑈 Can be defined by transformation of the basis vectors: 00 … (4 complex numbers) 01 … (4) 10 → … (4) Then linearity 11 → … (4) → Degrees→ of freedom: 32 16 1 = 15 (for qubits 4 1) 𝑘𝑘 unitary− −overall phase 𝑘𝑘 −

Reversible: = † 𝑈𝑈 𝑈𝑈 Examples of two-qubit gates 1. Trivial: tensor-product gates

𝑈𝑈 𝑉𝑉 Math structure: tensor-product of matrices

= 𝑉𝑉00 𝑉𝑉01 𝑉𝑉00 𝑉𝑉01 𝑈𝑈00 𝑈𝑈01 𝑉𝑉10 𝑉𝑉11 𝑉𝑉10 𝑉𝑉11 𝑈𝑈 ⊗ 𝑉𝑉 𝑉𝑉00 𝑉𝑉01 𝑉𝑉00 𝑉𝑉01 𝑈𝑈10 𝑈𝑈11 𝑉𝑉10 𝑉𝑉11 𝑉𝑉10 𝑉𝑉11 2– 5. Many gates are of controlled type: one qubit controls the other one (consider next) 2. Controlled-NOT (CNOT)

control target or

(Mermin’s book) 𝑋𝑋 Generalizes classical CNOT: target bit is flipped if control bit is 1 control target

00 |00 Matrix 1 0 0 0 00 01 |01 0 1 0 0 01 → 〉 10 |11 0 0 0 1 10 → 〉 11 |10 0 0 1 0 11 → 〉 Unitary matrix; can be checked, but actually trivial, → 〉 because a permutation of computational basis

00 + 01 + 10 + 11 00 + 01 + 10 + 11

𝛼𝛼0 𝛼𝛼1 𝛼𝛼2 𝛼𝛼3 ⟶ 𝛼𝛼0 𝛼𝛼1 𝛼𝛼3 𝛼𝛼2 CNOT (cont.) control target Notation: CNOT or (Mermin’s book) control target 𝑖𝑖𝑖𝑖 𝐶𝐶𝑖𝑖𝑖𝑖 CNOT = | for computational basis

qubit10 1𝑥𝑥 qubit𝑦𝑦 0 𝑥𝑥 𝑦𝑦addition⊕ 𝑥𝑥〉 modulo 2 (again, transformation for other states defined by linearity)

CNOT = |

Actually, not possible 01to say that nothing happens to the control qubit; this is true only if it is |0 or |1 . If control qubit is in𝑥𝑥 a superposition𝑦𝑦 𝑥𝑥 ⊕ state,𝑦𝑦 𝑦𝑦it 〉gets entangled with the target qubit. Then it will not have a state by itself, and it may depend on what happens next with the target qubit. 〉 〉 0 + |1 0 1 00 01 + 10 11 Example = 2 2 2 〉 − − − Control changes, 00 ⊗ 01 + 11 10 0 |1 0 ⟶1 while target the = same! 2 2 2 − − − 〉 − ⟶ ⊗ 3. Controlled-Z (CZ) control target Phase-flip of target if control is |1

〉 control target 𝑍𝑍 00 |00 Matrix 1 0 0 0 00 01 |01 0 1 0 0 01 → 〉 10 |10 0 0 1 0 10 → 〉 11 |11 0 0 0 1 11 → 〉 Somewhat→ − surprisingly,〉 symmetric −

= = 𝑍𝑍 𝑍𝑍 (Nielsen-Chuang) 4. Controlled-phase (C-phase)

Phase-S gate if control is |1

〉 control target 𝑆𝑆 00 |00 Matrix 1 0 0 0 00 01 |01 0 1 0 0 01 → 〉 10 |10 0 0 1 0 10 → 〉 11 |11 0 0 0 11 → 〉 Also symmetric → 𝑖𝑖 〉 𝑖𝑖 1 0 0 0 0 1 0 0 Note that often controlled-phase means 0 0 1 0 0 0 0 𝑖𝑖𝑖𝑖 𝑒𝑒 Examples of two-qubit gates (cont.)

5. Any controlled-

𝑈𝑈

𝑈𝑈 5. SWAP

(Nielsen-Chuang)

00 |00 1 0 0 0 Notation SWAP 01 |10 0 0 1 0 → 〉 𝑖𝑖𝑖𝑖 10 |01 0 1 0 0 (Mermin) → 〉 11 |11 0 0 0 1 𝑖𝑖𝑖𝑖 → 〉 Symmetric 𝑆𝑆 00 + → 01 〉+ 10 + 11 00 + 01 + 10 + 11

𝛼𝛼0 𝛼𝛼1 𝛼𝛼2 𝛼𝛼3 ⟶ 𝛼𝛼0 𝛼𝛼2 𝛼𝛼1 𝛼𝛼3 Useful relations between two-qubit gates

1. CNOT = C = SWAP = 1 2 2 2 𝑖𝑖𝑖𝑖 𝑍𝑍𝑖𝑖𝑖𝑖 𝑖𝑖𝑖𝑖 � 2. CNOT = CNOT

𝑖𝑖𝑖𝑖 𝑖𝑖 𝑗𝑗 𝑗𝑗𝑗𝑗 𝑖𝑖 𝑗𝑗 𝐻𝐻 𝐻𝐻 = 𝐻𝐻 𝐻𝐻 𝐻𝐻 𝐻𝐻 So, who controls whom is a matter of𝐻𝐻 preference!𝐻𝐻 Proof = = = 𝑍𝑍

because = (if𝐻𝐻 control=1)𝑍𝑍 𝐻𝐻 symmetric C 𝐻𝐻 𝐻𝐻similar to the first step: while = 1 (if control=0) = , = 1 𝐻𝐻𝐻𝐻2 𝐻𝐻 𝑋𝑋 𝑍𝑍 2 𝐻𝐻 � = Sufficient𝐻𝐻𝐻𝐻𝐻𝐻 to𝑍𝑍 prove𝐻𝐻 only� for basis states! 𝐻𝐻 𝐻𝐻 𝐻𝐻 𝐻𝐻 CNOT = CNOT (cont.)

Another proof 𝑖𝑖𝑖𝑖 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 𝑗𝑗𝑗𝑗 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 CNOT = + + = 1 1 1 0 0 0 1 𝑖𝑖𝑖𝑖 2 𝐼𝐼𝑖𝑖 selects𝑍𝑍𝑖𝑖 𝐼𝐼𝑗𝑗 2 𝐼𝐼𝑖𝑖 −selects𝑍𝑍𝑖𝑖 𝑋𝑋𝑗𝑗 0 0 state |0 0 1 state |1 𝐼𝐼 ≡ � (note that rearrange = + 〉+ =〉 corresponds to ) 1 1 𝑋𝑋 ↔ 𝑍𝑍 𝑖𝑖 𝑗𝑗 𝑗𝑗 𝑖𝑖 𝑗𝑗 𝑗𝑗 now exchange order and𝐼𝐼 2 multiply𝐼𝐼 𝑋𝑋 by 1 from𝑍𝑍 2 both𝐼𝐼 − sides𝑋𝑋 𝑖𝑖 ↔ 𝑗𝑗

= + +� = 1 1 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 2 𝐼𝐼𝑗𝑗 𝑋𝑋𝑗𝑗 𝐼𝐼𝑖𝑖 2 𝐼𝐼𝑗𝑗 − 𝑋𝑋𝑗𝑗 𝑍𝑍𝑖𝑖 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 ( = , = + + = = ) 1 1 𝐻𝐻𝐻𝐻𝐻𝐻 𝑍𝑍 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 2 𝐼𝐼𝑗𝑗 𝑍𝑍𝑗𝑗 𝐼𝐼𝑖𝑖 2 𝐼𝐼𝑗𝑗 − 𝑍𝑍𝑗𝑗 𝑋𝑋𝑖𝑖 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 𝐻𝐻𝐻𝐻𝐻𝐻 𝑋𝑋 CNOT 𝑗𝑗𝑗𝑗 = CNOT

𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 𝑗𝑗𝑗𝑗 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 CNOT = CNOT (cont.)

One more (direct) proof𝑖𝑖𝑖𝑖 Let𝐻𝐻 𝑖𝑖us𝐻𝐻 𝑗𝑗prove the𝑗𝑗 opposite𝑗𝑗 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 (equivalent) relation = 𝑖𝑖 𝐻𝐻 𝐻𝐻 𝑗𝑗 𝐻𝐻 𝐻𝐻 0 + 1 0 + 1 1 00 = 00 + 01 + 10 + 11 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 2 2 2 CNOT⟶ 1 ⟶ 00 + 01 + 11 + 10 |00 (as should be) 𝑖𝑖𝑖𝑖 2 𝑖𝑖 𝑗𝑗 (the same) 𝐻𝐻 𝐻𝐻 ⟶ ⟶ 〉 0 + 1 0 1 1 01 = 00 01 + 10 11 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 2 2 2 − CNOT ⟶1 0− |1 ) 0 − 0 |1⟶) 1 00 01 + 11 10 = = 𝑖𝑖𝑖𝑖 2 2 0 1 0 1 − 〉 − − 〉 ⟶ − − = |11 (as should be) 2 2 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 − − since = 1 Two more initial states ⟶ 〉 2 𝐻𝐻 � CNOT = CNOT (cont.)

𝑖𝑖𝑖𝑖 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 𝑗𝑗𝑗𝑗 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 = (equivalent relation, ) 𝑖𝑖 𝐻𝐻 𝐻𝐻 𝑖𝑖 ↔ 𝑗𝑗 𝑗𝑗 𝐻𝐻Already showed:𝐻𝐻 00 |00 , 01 |11

0 1 0 + 1 CNOT ⟶0 0 +〉1 1 1⟶+ 0 〉 0 1 0 + 1 10 = |10 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 2 2 𝑖𝑖𝑖𝑖 2 2 2 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 − − − ⟶ ⟶ (for brevity do not write ket-notation)⟶ 〉

0 1 0 1 CNOT 0 0 1 1 1 0 0 + 1 0 1 11 = |01 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 2 2 𝑖𝑖𝑖𝑖 2 2 2 𝐻𝐻𝑖𝑖𝐻𝐻𝑗𝑗 − − − − − − ⟶ ⟶ ⟶ 〉 We proved the relation for 4 initial basis states ⇒ should hold for any initial state

Important example, it shows that CNOT is not a one-way action, this is an interaction (has “quantum back-action”) Useful relations between two-qubit gates (cont.)

3. SWAP = CNOT CNOT CNOT

𝑖𝑖𝑖𝑖 𝑖𝑖𝑗𝑗 𝑗𝑗𝑗𝑗 𝑖𝑖𝑗𝑗 =

Proof Again, consider only (computational) basis states for initial state CNOT CNOT

𝑖𝑖𝑖𝑖 𝑗𝑗𝑗𝑗 = 𝑥𝑥 𝑖𝑖 𝑦𝑦 𝑗𝑗CNOT⟶ 𝑥𝑥 𝑖𝑖 𝑥𝑥 ⊕ 𝑦𝑦 𝑗𝑗 ⟶ 𝑥𝑥 ⊕ 𝑥𝑥 ⊕ 𝑦𝑦 𝑖𝑖 𝑥𝑥 ⊕ 𝑦𝑦 𝑗𝑗 𝑦𝑦 𝑖𝑖 𝑥𝑥 ⊕ 𝑦𝑦 𝑗𝑗 ⟶ = 𝑖𝑖𝑖𝑖 ⟶ 𝑦𝑦 𝑖𝑖 𝑥𝑥 ⊕ 𝑦𝑦 ⊕ 𝑦𝑦 𝑗𝑗 𝑦𝑦 𝑖𝑖 𝑥𝑥 𝑗𝑗

Three-qubit gates

Any unitary 8 × 8 matrix (overall phase is not important) 𝑈𝑈 In general characterized by 4 1 = 63 real numbers 3 − Two most important 3-qubit gates: Toffoli and Fredkin

Paper “Reversible computing” by T. Toffoli, Lecture notes in computer science, vol. 85 (1980), ICALP 1980. “Conservative logic” by Edward Fredkin and Tommaso Toffoli, Int. J. Theor. Phys. 21, 219, (1982), Toffoli gate

Toffoli gate: controlled-controlled-NOT Flip target if both controls are 1 1 110 |111 controls 1 1 0 other basis states 1 ↔ 〉 target do not change 1 1 0 0 1 1 0 Can be constructed with CNOTs and 1-qubit gates (6 CNOTs needed)

Classical Toffoli gate is sufficient for classical reversible computation (to beat informational limit for energy dissipation in computation). Cannot be decomposed into 2-bit gates (in contrast to the quantum case), minimal gate for reversible computation. Realizes AND if target 0, NAND if target 1. Fredkin gate

Fredkin gate: controlled-SWAP

1 101 |110 control 1 1 0 targets other basis↔ states〉 1 do not change 1 0 1 0 1 0 1

Classical Fredkin realizes AND (in lower target) if lower target is initially 0. No fan-out gate (no-cloning theorem) Theorem: impossible to realize fan-out gate | | |0 | 𝜓𝜓〉 𝜓𝜓〉 𝑈𝑈 Proof〉 Assume 0 0 = 𝜓𝜓0〉 0 1 0 = 1 1 𝑈𝑈 Then ( 0 + |1 ) 0 = 0 0 + |1 |1 , while for desired cloning 𝑈𝑈 ( 0 𝑈𝑈+ 𝛼𝛼|1 ) 0 𝛽𝛽 〉( 0 +𝛼𝛼 |1 )( 0𝛽𝛽 +〉 1〉 ) = = 0 0 + 1 1 + 0 |1 + |1 |0 (a different state!) 𝛼𝛼 2𝛽𝛽 〉 ⟶2 𝛼𝛼 𝛽𝛽 〉 𝛼𝛼 𝛽𝛽 More general𝛼𝛼 proof 𝛽𝛽 Assume𝛼𝛼 𝛼𝛼 〉 0 =𝛼𝛼𝛼𝛼 〉 〉 0 = 𝑈𝑈 𝜓𝜓 𝜓𝜓 𝜓𝜓 Unitary operation preserves inner product,𝑈𝑈 𝜙𝜙 therefore𝜙𝜙 𝜙𝜙 | = . 2 This is possible only when | = 0 or 1 (i.e., can clone〈𝜙𝜙 only𝜓𝜓〉 orthogonal𝜙𝜙 𝜓𝜓 states)

〈𝜙𝜙 𝜓𝜓〉