mirror of
https://github.com/quantumjim/Quantum-Computation-course-Basel.git
synced 2025-11-08 23:24:27 +01:00
delete typo
This commit is contained in:
parent
eb6795a4b2
commit
9167dbe8c2
@ -87,7 +87,7 @@
|
||||
"Consider the controlled-$Z$ gate\n",
|
||||
"\n",
|
||||
"$$\n",
|
||||
"CZ = |1\\rangle \\langle 1 | \\otimes I + |0\\rangle \\langle 0 | \\otimes Z,\n",
|
||||
"CZ = |0\\rangle \\langle 0 | \\otimes I + |1\\rangle \\langle 1 | \\otimes Z,\n",
|
||||
"$$\n",
|
||||
"\n",
|
||||
"and the following two families of states.\n",
|
||||
@ -101,106 +101,6 @@
|
||||
"\n",
|
||||
"* (b) Apply the $CZ$ gate to the first two qubits of the three qubit state $|a\\rangle \\otimes |\\Phi^+\\rangle$. Again find the reduced density matrices, and their eigenvalues and vectors. Are the eigenvalues of both qubits still the same?"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Hints\n",
|
||||
"\n",
|
||||
"### 1\n",
|
||||
"\n",
|
||||
"The truth table is reversable, so it would be possible to create a solution using only three qubits. But it would also be hard. In the solution I present the least elegant solution that uses 6 qubits in all. They should know that such non-elegant solutions are an option.\n",
|
||||
"\n",
|
||||
"### 2\n",
|
||||
"\n",
|
||||
"Looking at Hello Qiskit (or otherwise looking up Bell tests) and using the mentioned example should be enough to set them on the right path.\n",
|
||||
"\n",
|
||||
"### 3 and 4\n",
|
||||
"\n",
|
||||
"Just some matrix stuff. Maybe doing some partial trace examples with them would be good, though."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Solutions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Solution 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from qiskit import QuantumCircuit\n",
|
||||
"from qiskit_aer import AerSimulator\n",
|
||||
"from qiskit.circuit.library.standard_gates import XGate\n",
|
||||
"\n",
|
||||
"# create a controlled-controlled-controlled-X gate\n",
|
||||
"# This performs an X on the target qubit if the three controls are all |1>\n",
|
||||
"cccx = XGate().control(3)\n",
|
||||
"\n",
|
||||
"def boolean_gate(abc):\n",
|
||||
"\n",
|
||||
" qc = QuantumCircuit(6,3)\n",
|
||||
"\n",
|
||||
" # encode a, b and c in qubits 0, 1 and 2, respectively\n",
|
||||
" if abc[0]=='1':\n",
|
||||
" qc.x(0)\n",
|
||||
" if abc[1]=='1':\n",
|
||||
" qc.x(1)\n",
|
||||
" if abc[2]=='1':\n",
|
||||
" qc.x(2)\n",
|
||||
"\n",
|
||||
" # we'll encode d, e and f in qubits 3, 4 and 5, respectively\n",
|
||||
" # for each input we'll do the following process\n",
|
||||
" # 1 - rotate that input to 111\n",
|
||||
" # 2 - implement cccxs whose targets are any output bits that should be 1\n",
|
||||
" # 3 - undo step 1\n",
|
||||
" # This will then prepare the correct outputs (although in a needlessly long way)\n",
|
||||
"\n",
|
||||
" # 000 -> 010\n",
|
||||
" if abc == '000':\n",
|
||||
" qc.x([0,1,2])\n",
|
||||
" qc.append(cccx, [0,1,2, 4])\n",
|
||||
" qc.x([0,1,2])\n",
|
||||
"\n",
|
||||
" # 001 -> 110\n",
|
||||
" if abc == '001':\n",
|
||||
" qc.x([0,1])\n",
|
||||
" qc.append(cccx, [0,1,2, 3])\n",
|
||||
" qc.append(cccx, [0,1,2, 4])\n",
|
||||
" qc.x([0,1])\n",
|
||||
"\n",
|
||||
" # 010 -> 001\n",
|
||||
" if abc == '010':\n",
|
||||
" qc.x([0,2])\n",
|
||||
" qc.append(cccx, [0,1,2, 5])\n",
|
||||
" qc.x([0,2])\n",
|
||||
"\n",
|
||||
" # and so on for the other inputs that I can't be bothered to do\n",
|
||||
"\n",
|
||||
" # finally we measure the output bits to get the output\n",
|
||||
" qc.measure([3,4,5], [2,1,0])\n",
|
||||
"\n",
|
||||
" return AerSimulator().run(qc, shots=1, memory=True).result().get_memory()[0]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user