{"id":5238,"date":"2025-01-02T08:53:40","date_gmt":"2025-01-02T07:53:40","guid":{"rendered":"https:\/\/www.islandwalking.com\/wordpress\/?p=5238"},"modified":"2025-01-02T11:10:44","modified_gmt":"2025-01-02T10:10:44","slug":"quantum-teleportation-part-iii","status":"publish","type":"post","link":"https:\/\/www.islandwalking.com\/wordpress\/quantum-teleportation-part-iii\/","title":{"rendered":"Quantum Teleportation Part III"},"content":{"rendered":"<p>Believe it or not, even with their strict limitations, the fairly simplistic functions from the last post are sufficient building blocks to demonstrate a simple quantum circuit. Now we just have to declare the necessary quantum gates and initialize the three input qubits and we are ready to actually &#8220;build&#8221; the circuit.<\/p>\n<p>This is the matrix definition of the quantum gates needed (see the drawing in the first post, &#8220;I&#8221; is needed to expand the circuit to more bits as all the gates have either a one or two bit input):<\/p>\n<blockquote>\n<pre>X=[[0,1],[1,0]]\r\nZ=[[1,0],[0,-1]]\r\nI=[[1,0],[0,1]]\r\nH=[[1\/sqrt(2),1\/sqrt(2)],[1\/sqrt(2),-1\/sqrt(2)]]\r\nCNOT=[[1,0,0,0],[0,1,0,0],[0,0,0,1],[0,0,1,0]]\r\n\r\n<\/pre>\n<\/blockquote>\n<p>The usual suspects (aka &#8220;Alice&#8221; and &#8220;Bob&#8221;) can now start doing their qubit dance routine. Let us give Alice a nice little qubit, then initialize the inputs with it (other inputs are zeroed):<\/p>\n<blockquote>\n<pre>#Alice qubit\r\nq=[[-1\/sqrt(2)],[-1\/sqrt(2)]]\r\nprint(\"Alice qubit:\",q)\r\n\r\n#Initialize inputs\r\nq=[q[0],[0],[0],[0],q[1],[0],[0],[0]]<\/pre>\n<\/blockquote>\n<p>Creating the circuit:<\/p>\n<blockquote>\n<pre>#Build circuit\r\nU=kron(I,kron(H,I))\r\nU=mult(kron(I,CNOT),U)\r\nU=mult(kron(CNOT,I),U)\r\nU=mult(kron(H,kron(I,I)),U)<\/pre>\n<\/blockquote>\n<p>Running the circuit on the three inputs:<\/p>\n<blockquote>\n<pre>#Apply circuit\r\nq=mult(U,q)<\/pre>\n<\/blockquote>\n<p>Alice now measures her qubits, the result will be made available to Bob:<\/p>\n<blockquote>\n<pre>#Alice measurements\r\nb0=qbit(0,M(q))\r\nq=qbitset(0,b0,q)\r\nb1=qbit(1,M(q))\r\nq=qbitset(1,b1,q)\r\nprint(\"Alice measurements:\",b0,b1)<\/pre>\n<\/blockquote>\n<p>Bob now, based on the measurements from Alice, can do some operations on his entangled qubit (using a small one qubit input circuit, finally turning his qubit into something matching the one Alice started with):<\/p>\n<blockquote>\n<pre>#Bob qubit\r\nr=[[0],[0]]\r\nfor i in range(len(q)):\r\n  if i&amp;1==1:\r\n    r[1][0]+=q[i][0]\r\n  else:\r\n    r[0][0]+=q[i][0]\r\n\r\n#Conditionally apply X and\/or Z\r\nif b1==1:\r\n  r=mult(X,r)\r\nif b0==1:\r\n  r=mult(Z,r)\r\nprint(\"Bob qubit:\",r)\r\n<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Believe it or not, even with their strict limitations, the fairly simplistic functions from the last post are sufficient building blocks to demonstrate a simple quantum circuit. Now we just have to declare the necessary quantum gates and initialize the three input qubits and we are ready to actually &#8220;build&#8221; the circuit. This is the &hellip; <a class=\"read-excerpt\" href=\"https:\/\/www.islandwalking.com\/wordpress\/quantum-teleportation-part-iii\/\">Continue reading <span class=\"meta-nav\">&raquo;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5238","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/posts\/5238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/comments?post=5238"}],"version-history":[{"count":15,"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/posts\/5238\/revisions"}],"predecessor-version":[{"id":5257,"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/posts\/5238\/revisions\/5257"}],"wp:attachment":[{"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.islandwalking.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}