Untitled.ipynb (5462B)
1 { 2 "cells": [ 3 { 4 "cell_type": "code", 5 "execution_count": 6, 6 "id": "5793ddb1", 7 "metadata": {}, 8 "outputs": [], 9 "source": [ 10 "import numpy as np\n", 11 "from scipy.linalg import hadamard\n", 12 "from sympy import *\n", 13 "from sympy.physics.quantum import TensorProduct\n", 14 "\n", 15 "p = Symbol('p')" 16 ] 17 }, 18 { 19 "cell_type": "code", 20 "execution_count": 289, 21 "id": "eedef28c", 22 "metadata": {}, 23 "outputs": [ 24 { 25 "data": { 26 "text/latex": [ 27 "$\\displaystyle 0.5 p + 0.5$" 28 ], 29 "text/plain": [ 30 "0.5*p + 0.5" 31 ] 32 }, 33 "execution_count": 289, 34 "metadata": {}, 35 "output_type": "execute_result" 36 } 37 ], 38 "source": [ 39 "# AUFGABE 3\n", 40 "d=2\n", 41 "b_1 = [Matrix([1, 0]), Matrix([0, 1])]\n", 42 "b_3 = [1/sqrt(2)*Matrix([1, 1]), 1/sqrt(2)*Matrix([1, -1])]\n", 43 "b_2 = [1/sqrt(2)*Matrix([1, 1j]), 1/sqrt(2)*Matrix([1, -1j])]\n", 44 "\n", 45 "\n", 46 "basis_2 = [b_1, b_2, b_3]\n", 47 "rho_2 = Matrix(b_1) @ Matrix(b_1).H\n", 48 "rho_iso_2 = (1-p)*1/d**2 * eye(d**2) + p*rho_2\n", 49 "\n", 50 "\n", 51 "simplify(mubs(basis_2, rho_iso_2, d=2, m=2))" 52 ] 53 }, 54 { 55 "cell_type": "code", 56 "execution_count": 253, 57 "id": "ca4202a1", 58 "metadata": {}, 59 "outputs": [ 60 { 61 "data": { 62 "text/latex": [ 63 "$\\displaystyle 7.11111111111111 p + 0.888888888888889$" 64 ], 65 "text/plain": [ 66 "7.11111111111111*p + 0.888888888888889" 67 ] 68 }, 69 "execution_count": 253, 70 "metadata": {}, 71 "output_type": "execute_result" 72 } 73 ], 74 "source": [ 75 "# AUFGABE3\n", 76 "d = 3\n", 77 "w = 1/2 * (-1 + 1j*sqrt(3))\n", 78 "\n", 79 "b1 = [Matrix([1, 0, 0]), Matrix([0, 1, 0]), Matrix([0, 0, 1])]\n", 80 "b2 = [1/sqrt(3) *Matrix([1, 1, 1]),1/sqrt(3) * Matrix([1, w, w**2]), 1/sqrt(3) *Matrix([1, w**2, w])]\n", 81 "b3 = [1/sqrt(3) *Matrix([1, w, w]), 1/sqrt(3) *Matrix([1, w**2, 1]), 1/sqrt(3) *Matrix([1, 1, w**2])]\n", 82 "b4 = [1/sqrt(3) *Matrix([1, w**2, w**2]), 1/sqrt(3) *Matrix([1, w, 1]), 1/sqrt(3) *Matrix([1, 1, w])]\n", 83 "\n", 84 "basis_3 = [b1, b2, b3, b4]\n", 85 "rho_3 = Matrix(b1) @ Matrix(b1).T\n", 86 "rho_iso_3 = (1-p)*1/d**2 * eye(d**2) + p*rho_3\n", 87 "\n", 88 "simplify(mubs(basis_3, rho_iso_3, d=3, m=4))" 89 ] 90 }, 91 { 92 "cell_type": "code", 93 "execution_count": 302, 94 "id": "d7c7b77f", 95 "metadata": {}, 96 "outputs": [ 97 { 98 "data": { 99 "text/latex": [ 100 "$\\displaystyle 1.33333333333333 q$" 101 ], 102 "text/plain": [ 103 "1.33333333333333*q" 104 ] 105 }, 106 "execution_count": 302, 107 "metadata": {}, 108 "output_type": "execute_result" 109 } 110 ], 111 "source": [ 112 "# AUFGABE4\n", 113 "q = Symbol('q')\n", 114 "\n", 115 "def pp(basis, d):\n", 116 " pp = zeros(d**2)\n", 117 " for i in range(d):\n", 118 " for j in range(d):\n", 119 " pp += TensorProduct(basis[0][j], basis[0][i]) @\\\n", 120 " TensorProduct(basis[0][i], basis[0][j]).H\n", 121 " \n", 122 " p_sym = eye(d**2) + pp\n", 123 " p_asym = eye(d**2) - pp\n", 124 " return p_sym, p_asym\n", 125 "\n", 126 "d = 3\n", 127 "p_sym_3, p_asym_3 = pp(basis_3, d=d)\n", 128 "rho_W_3 = q * p_sym_3/(d*(d+1)) + (1-q)*p_asym_3/(d*(d-1))\n", 129 "simplify(mubs(basis_3, rho_W_3, d=3, m=4))" 130 ] 131 }, 132 { 133 "cell_type": "code", 134 "execution_count": 298, 135 "id": "fcc5a083", 136 "metadata": {}, 137 "outputs": [], 138 "source": [ 139 "def mubs(basis, rho, d, m):\n", 140 " I_MUB = 0\n", 141 " for k in range(m):\n", 142 " for i in range(d-1):\n", 143 " I_MUB += (TensorProduct(basis[k][i]@basis[k][i].H, (basis[k][i] @ basis[k][i].H)) @ rho).trace()\n", 144 " \n", 145 " return I_MUB" 146 ] 147 }, 148 { 149 "cell_type": "code", 150 "execution_count": 297, 151 "id": "135fbb35", 152 "metadata": {}, 153 "outputs": [ 154 { 155 "data": { 156 "text/latex": [ 157 "$\\displaystyle \\frac{\\sqrt{2} \\sin{\\left(2 p + \\frac{\\pi}{4} \\right)}}{2} + 1$" 158 ], 159 "text/plain": [ 160 "sqrt(2)*sin(2*p + pi/4)/2 + 1" 161 ] 162 }, 163 "execution_count": 297, 164 "metadata": {}, 165 "output_type": "execute_result" 166 } 167 ], 168 "source": [ 169 "# AUFGABE 2\n", 170 "psi = Matrix([cos(p), 0, 0, sin(p)])\n", 171 "rho = psi @ psi.T\n", 172 "simplify(mubs(basis_2, rho, d=2, m=3))" 173 ] 174 }, 175 { 176 "cell_type": "code", 177 "execution_count": null, 178 "id": "44595f1a", 179 "metadata": {}, 180 "outputs": [], 181 "source": [] 182 }, 183 { 184 "cell_type": "code", 185 "execution_count": null, 186 "id": "57e2b6f5", 187 "metadata": {}, 188 "outputs": [], 189 "source": [] 190 }, 191 { 192 "cell_type": "code", 193 "execution_count": null, 194 "id": "5d597e50", 195 "metadata": {}, 196 "outputs": [], 197 "source": [] 198 }, 199 { 200 "cell_type": "code", 201 "execution_count": null, 202 "id": "7b34dc5c", 203 "metadata": {}, 204 "outputs": [], 205 "source": [] 206 }, 207 { 208 "cell_type": "code", 209 "execution_count": null, 210 "id": "b7008830", 211 "metadata": {}, 212 "outputs": [], 213 "source": [] 214 } 215 ], 216 "metadata": { 217 "kernelspec": { 218 "display_name": "Python 3", 219 "language": "python", 220 "name": "python3" 221 }, 222 "language_info": { 223 "codemirror_mode": { 224 "name": "ipython", 225 "version": 3 226 }, 227 "file_extension": ".py", 228 "mimetype": "text/x-python", 229 "name": "python", 230 "nbconvert_exporter": "python", 231 "pygments_lexer": "ipython3", 232 "version": "3.9.5" 233 } 234 }, 235 "nbformat": 4, 236 "nbformat_minor": 5 237 }