mirror of
https://github.com/quantumjim/Quantum-Computation-course-Basel.git
synced 2025-11-24 09:24:31 +01:00
74 lines
2.1 KiB
Plaintext
74 lines
2.1 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"\"\"\"\n",
|
|
"LOCC cannot create entanglement. Simulate LOCC-like maps (local unitaries + classical randomness) on product states.\n",
|
|
"\n",
|
|
"Exercises:\n",
|
|
"- Add classical mixing over different local unitaries and show separability persists for mixed states.\n",
|
|
"\"\"\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Entangled after local? False\n",
|
|
"Entangled after RXX? True\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import numpy as np\n",
|
|
"from qiskit import QuantumCircuit\n",
|
|
"from qiskit.quantum_info import Statevector\n",
|
|
"\n",
|
|
"def entangled(psi):\n",
|
|
" s = np.linalg.svd(psi.data.reshape(2,2), compute_uv=False)\n",
|
|
" return abs(s[0]*s[1])>1e-12 # Basically 0 if separable, i.e. not entangled.\n",
|
|
"\n",
|
|
"psi = Statevector.from_label(\"00\")\n",
|
|
"local = QuantumCircuit(2) # A separable state.\n",
|
|
"for q in range(2): local.rx(0.7,q); local.ry(0.3,q); local.rz(0.2,q) # Example local unitaries. Change as desired.\n",
|
|
"psi_local = psi.evolve(local)\n",
|
|
"print(\"Entangled after local?\", entangled(psi_local)) #Whateve separable state, whatever local unitaries, should be False.\n",
|
|
"\n",
|
|
"ent = QuantumCircuit(2); ent.rxx(0.6,0,1) # An entangling operation.\n",
|
|
"psi_ent = psi_local.evolve(ent)\n",
|
|
"print(\"Entangled after RXX?\", entangled(psi_ent)) #Whatever entagnled state, whatever locc, should be True."
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.8"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|