microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.2.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

katas/content/multi_qubit_gates/compound_gate/solution.md

45lines · modecode

1One way to represent a multi-qubit transformation is to use the tensor product of gates acting on subsets of qubits. For example, if you have 2 qubits, applying the $Z$ gate on the first qubit and the $X$ gate on the second qubit will create this matrix:
2
3$$
4Z \otimes X =
5\begin{bmatrix} 1 & 0 \\\ 0 & -1 \end{bmatrix} \otimes \begin{bmatrix} 0 & 1 \\\ 1 & 0 \end{bmatrix} =
6\begin{bmatrix} 0 & 1 & 0 & 0 \\\ 1 & 0 & 0 & 0 \\\ 0 & 0 & 0 & -1 \\\ 0 & 0 & -1 & 0 \end{bmatrix}
7$$
8
9With this in mind, let's see how to reverse engineer the target matrix above to find the 3 gates which, acting on individual qubits, together form the target transformation.
10
11Start by noticing that the top right and bottom left quadrants of the target matrix are filled with $0$'s, and the bottom right quadrant equals to the top left one, multiplied by $i$. This hints at applying the $S$ gate to the first qubit:
12
13$$
14Q =
15\begin{bmatrix} 1 & 0 \\\ 0 & i \end{bmatrix} \otimes
16\begin{bmatrix}
17 0 & -i & 0 & 0 \\\
18 i & 0 & 0 & 0 \\\
19 0 & 0 & 0 & -i \\\
20 0 & 0 & i & 0
21\end{bmatrix} =
22\begin{bmatrix}
23 0 & -i & 0 & 0 & 0 & 0 & 0 & 0 \\\
24 i & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\
25 0 & 0 & 0 & -i & 0 & 0 & 0 & 0 \\\
26 0 & 0 & i & 0 & 0 & 0 & 0 & 0 \\\
27 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\
28 0 & 0 & 0 & 0 & -1 & 0 & 0 & 0 \\\
29 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\
30 0 & 0 & 0 & 0 & 0 & 0 & -1 & 0
31\end{bmatrix}
32$$
33
34Now the $4 \times 4$ matrix has all $0$s in the top right and bottom left quadrants, and the bottom right quadrant equals to the top left one. This means the second qubit has the $I$ gate applied to it, and the third qubit - the $Y$ gate:
35
36$$
37Q =
38\begin{bmatrix} 1 & 0 \\\ 0 & i \end{bmatrix} \otimes \begin{bmatrix} 1 & 0 \\\ 0 & 1 \end{bmatrix} \otimes
39\begin{bmatrix} 0 & -i \\\ i & 0 \end{bmatrix} = S \otimes I \otimes Y
40$$
41
42@[solution]({
43 "id": "multi_qubit_gates__compound_gate_solution",
44 "codePath": "./Solution.qs"
45})
46