Files
Quantum-Computation-course-…/extra_resources/Entanglement_extra/7_Separability.ipynb

94 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\nFor 2×2 and 2×3 systems, the Positive Partial Transpose (PPT) criterion is necessary and sufficient for separability.\\n\\nExercises:\\n- Extend to a 2×3 example by padding qubits or adding a qutrit toy model with dims=(2,3).\\n- Wrap into a helper function `is_entangled_ppt(rho, dims)`.\\n'"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"\"\"\n",
"For 2×2 and 2×3 systems, the Positive Partial Transpose (PPT) criterion is necessary and sufficient for separability.\n",
"\n",
"Exercises:\n",
"- Extend to a 2×3 example by padding qubits or adding a qutrit toy model with dims=(2,3).\n",
"- Wrap into a helper function `is_entangled_ppt(rho, dims)`.\n",
"\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"p=1.0 min eig(ρ^T_B)=-5.000000e-01 ENTANGLED\n",
"p=0.8 min eig(ρ^T_B)=-3.500000e-01 ENTANGLED\n",
"p=0.6 min eig(ρ^T_B)=-2.000000e-01 ENTANGLED\n",
"p=0.4 min eig(ρ^T_B)=-5.000000e-02 ENTANGLED\n"
]
}
],
"source": [
"import numpy as np\n",
"from qiskit.quantum_info import Statevector, DensityMatrix\n",
"\n",
"phi = Statevector([1,0,0,1])/np.sqrt(2)\n",
"rho_pure = DensityMatrix(phi).data\n",
"I4 = np.eye(4)/4\n",
"\n",
"def isotropic(p):\n",
" # |Φ+> density matrix with simple depolarizing noise when p<1\n",
" return p*rho_pure + (1-p)*I4\n",
"\n",
"for p in [1.0, 0.8, 0.6, 0.4]:\n",
" rho = isotropic(p)\n",
" rho_pt = DensityMatrix.partial_transpose(DensityMatrix(rho), [1]).data\n",
" eig = np.linalg.eigvalsh(rho_pt)\n",
" print(f\"p={p} min eig(ρ^T_B)={eig.min(): .6e} {'ENTANGLED' if eig.min()< -1e-10 else 'PPT'}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}