<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Md. Zubair</title>
    <description>The latest articles on DEV Community by Md. Zubair (@mdzubair9492).</description>
    <link>https://dev.to/mdzubair9492</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1251142%2Fd932ea87-f2b4-4121-b377-fc8e696e6377.jpeg</url>
      <title>DEV Community: Md. Zubair</title>
      <link>https://dev.to/mdzubair9492</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mdzubair9492"/>
    <language>en</language>
    <item>
      <title>Bernstein-Vazirani Algorithm in Qiskit</title>
      <dc:creator>Md. Zubair</dc:creator>
      <pubDate>Mon, 25 Mar 2024 05:39:19 +0000</pubDate>
      <link>https://dev.to/mdzubair9492/bernstein-vazirani-algorithm-in-qiskit-16gk</link>
      <guid>https://dev.to/mdzubair9492/bernstein-vazirani-algorithm-in-qiskit-16gk</guid>
      <description>&lt;p&gt;To understand it first there is a prerequisities to understand,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase Kickback&lt;/strong&gt;:&lt;br&gt;
Suppose we have a system of two qubits , two qubits are in differetn state, now we want to get the phase of one qubit to another, there comes phase kickback.&lt;/p&gt;

&lt;p&gt;Let a system of two qubits q1q0 . Here Taking q0 as |-&amp;gt; state and q1 as |+&amp;gt; state. Now we want q1 also as |-&amp;gt; . here we can apply a cx gate where control  is q1 and target is q0,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F21k3oixkwf2rxbrv519b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F21k3oixkwf2rxbrv519b.jpg" alt="Image description" width="718" height="953"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So now we can jump into the main algorithm. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;: Suppose we have a blackbox which contain a secret number and our goal is to get the secret number by giving query to the blackbox.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Classical Approach&lt;/strong&gt;: In classical approach for a n bit secret number we have to give n query . This works as follows,&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fknoh7velic6klrr6yzvi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fknoh7velic6klrr6yzvi.jpg" alt="Image description" width="617" height="806"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhybs3s4c8ueajf6ubs0a.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhybs3s4c8ueajf6ubs0a.jpg" alt="Image description" width="616" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Quantum Approach&lt;/strong&gt;": In this approach we only need 1 query to get the secret key. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5luakpauu6e4ob9nepka.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5luakpauu6e4ob9nepka.jpg" alt="Image description" width="616" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2buhid3mry3d5sen91i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl2buhid3mry3d5sen91i.jpg" alt="Image description" width="613" height="832"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here |x&amp;gt; is our query and |y&amp;gt; is auxiliary as this is reversible. For |y&amp;gt; we will use |1&amp;gt; state for using the phase kickback technique. &lt;/p&gt;

&lt;p&gt;Now what oracle does here ? The oracle is basically put cx gate where the secret key has 1. Now let's think about why we need to put cx gate here. First off all all qubits in |x&amp;gt; is in superposition of |+&amp;gt; state and the auxiliary is in |-&amp;gt; state. If we know if we again apply H gate on |-&amp;gt; state and then if we measure if we will get |1&amp;gt; which is our requirement. &lt;/p&gt;

&lt;p&gt;Now let's see the implementation part of this algorithm ,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswd4igvxg3m6w3tzpz1v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswd4igvxg3m6w3tzpz1v.png" alt="Image description" width="611" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we want to see how our circuit looks like, &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uc87dox3uzbgnd8p0gm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uc87dox3uzbgnd8p0gm.png" alt="Image description" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's see whether it has sucessfully generated the secret key or not .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvs0fvmhjns1ij5ykw66w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvs0fvmhjns1ij5ykw66w.png" alt="Image description" width="493" height="138"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Universal Gates making using Reversible Computing in QISKIT</title>
      <dc:creator>Md. Zubair</dc:creator>
      <pubDate>Sun, 10 Mar 2024 22:12:54 +0000</pubDate>
      <link>https://dev.to/mdzubair9492/universal-gates-making-using-reversible-computing-in-qiskit-gn1</link>
      <guid>https://dev.to/mdzubair9492/universal-gates-making-using-reversible-computing-in-qiskit-gn1</guid>
      <description>&lt;p&gt;There are different types of classical gates like AND, OR , NOT, NOR, NAND etc. If we think about it classically , Only the NOT gate is reversible and rests are not. &lt;br&gt;
By reversible I meant we can get the input value by looking at the value of output. If we look at the truth table of &lt;strong&gt;NOT gate&lt;/strong&gt;,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0qidvcv2yx5gvjlbpiw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg0qidvcv2yx5gvjlbpiw.png" alt="Image description" width="484" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can infer the input or the output value by looking at the other . &lt;/p&gt;

&lt;p&gt;But this is not the case with other gates. To understand it clearly , let's take &lt;strong&gt;OR gate&lt;/strong&gt; truth table,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nuuewe8ekzl6fblvzuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nuuewe8ekzl6fblvzuh.png" alt="Image description" width="500" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here , suppose by using or gate on 2 unknown bits you got the output 1, now can you infer from here the input values of 2 bits ? No you can't . It is because there can be 3 possibilites like 01,10,11.&lt;/p&gt;

&lt;p&gt;But we can do this in Quantum Computer. Quantum Computer is reversible according to the laws of physics .  Quantum Gates U are invertible (U^-1 = U^t) and hence quantum circuit (without measurement) are invertible . The idea for making it reversible is whenever you compute a gate save the inputs. So, And &amp;amp; OR gates should be implemented in a reversible manner . The idea is to create a 3-qubit circuit which donot modify the input bits and writes the output of 3rd bit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xv2ef28jc21elb2mgzg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xv2ef28jc21elb2mgzg.jpg" alt="Image description" width="624" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Reversible AND gates implementaion:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yce5nogs6dhwxg11nls.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yce5nogs6dhwxg11nls.jpg" alt="Image description" width="718" height="658"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is implemented using a Toffoli gate , It is revertible in the sense that given x1,x2 and y (xor) (x1 and x2) , we can compute back y.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdqapjz1yoh7l5weer3r.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdqapjz1yoh7l5weer3r.jpg" alt="Image description" width="608" height="820"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the Qiskit Implementation, &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2eez50ep5ie2egbiuxe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2eez50ep5ie2egbiuxe.png" alt="Image description" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output of the code will be , &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F17j02vu9nvpybckoqqow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F17j02vu9nvpybckoqqow.png" alt="Image description" width="349" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  OR gate Implementation:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnx0gn092u670awh6kmj1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnx0gn092u670awh6kmj1.jpg" alt="Image description" width="605" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now there can be a lot of ways to implement this, &lt;br&gt;
I am showing here two method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 1: By using the rule A xor B xor AB = A OR B&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyz6naydpkerk9lv5ej1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyz6naydpkerk9lv5ej1.jpg" alt="Image description" width="591" height="851"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbj1vafpeh8ayw2owqkj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbj1vafpeh8ayw2owqkj.png" alt="Image description" width="696" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method 2: Simply negating and using De-Morgan&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52eycdgz9qblq76b0oj6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52eycdgz9qblq76b0oj6.jpg" alt="Image description" width="720" height="1036"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq90zg90mljjwtbjr26lm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq90zg90mljjwtbjr26lm.png" alt="Image description" width="658" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  XOR gate Implementation:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk6immnq2l2mdo5hhe1qx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk6immnq2l2mdo5hhe1qx.jpg" alt="Image description" width="612" height="825"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fle1ixjm4qpjn4fwdzl0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fle1ixjm4qpjn4fwdzl0s.png" alt="Image description" width="678" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Superdense Coding-Math &amp; Implementation</title>
      <dc:creator>Md. Zubair</dc:creator>
      <pubDate>Fri, 09 Feb 2024 07:01:41 +0000</pubDate>
      <link>https://dev.to/mdzubair9492/superdense-coding-math-implementation-26ik</link>
      <guid>https://dev.to/mdzubair9492/superdense-coding-math-implementation-26ik</guid>
      <description>&lt;p&gt;For classical communication there is a limit on how much information can be send with a given number of bits. We can send no more than n bits of information using n bits. However, there are ways that we can push the boundary which are not possible classically. Hence, we can use superdense coding using quantum computer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is a procedure that allows someone to send two classical bits to another party using just a single qubit of information.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here we will use 4 types of gates while implementing this procedure.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;H gate&lt;/strong&gt; -&amp;gt; This puts a qubit into superposition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;X gate&lt;/strong&gt; -&amp;gt; X|0&amp;gt; -&amp;gt; |1&amp;gt; &amp;amp; X|1&amp;gt; -&amp;gt; |0&amp;gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CX gate&lt;/strong&gt; -&amp;gt; It takes two qubits one is control and another is target. If the control bit is 0 , it does nothing to the target qubit, otherwise if the control bit is 1, X gate is applied on target qubit. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Z gate&lt;/strong&gt; -&amp;gt; It only change the phase of a qubit when it is in |1&amp;gt; state i.e, Z|0&amp;gt; -&amp;gt; |0&amp;gt; , Z|1&amp;gt; -&amp;gt; -|1&amp;gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The procedure is implemented as follows,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F056r9uelk2m96wyygrjg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F056r9uelk2m96wyygrjg.jpg" alt="Image description" width="800" height="685"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For keeping track , we have put 4 track point here , namely W1,W2,W3,W4.&lt;/p&gt;

&lt;p&gt;Now let's see how this procedure works mathematically,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs568hk0djevcs33qtowf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs568hk0djevcs33qtowf.jpg" alt="Image description" width="800" height="1066"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk9ceyqngtusv692hu96n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk9ceyqngtusv692hu96n.jpg" alt="Image description" width="800" height="1157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjft2tdgnepe4eraa4u6w.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjft2tdgnepe4eraa4u6w.jpg" alt="Image description" width="800" height="966"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjufw2jwl9rww7f12hkxy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjufw2jwl9rww7f12hkxy.jpg" alt="Image description" width="800" height="1066"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdf1ppzez9qbekkc99xv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdf1ppzez9qbekkc99xv.jpg" alt="Image description" width="800" height="1066"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's see its coding part, here we will use Qiskit for the implementation,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from qiskit import QuantumCircuit,Aer,execute

qc_3rd_party = QuantumCircuit(2,2)

qc_3rd_party.h(1)

qc_3rd_party.cx(1,0)


message_list = ['00', '01', '10', '11']

qc_Alice = QuantumCircuit(2,2)

for msg in message_list:

    if msg[-2]=='1':

        qc_Alice.z(1)

    if msg[-1]=='1':

        qc_Alice.x(1)

    qc_Bob = QuantumCircuit(2,2)

    qc_Bob.cx(1,0)

    qc_Bob.h(1)

    qc_Bob.measure([0,1],[0,1])

    complete_qc = qc_3rd_party.compose(qc_Alice.compose(qc_Bob))

    backend = Aer.get_backend('qasm_simulator')

    print(f'For message = {msg}\n')

    count = backend.run(complete_qc).result().get_counts()

    print(count,"\n")

    qc_3rd_party.data=[]

    qc_Alice.data=[]

    qc_Bob.data=[]


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output of the code is ,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6epzwueihfznfowlo0di.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6epzwueihfznfowlo0di.png" alt="Image description" width="399" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
