Understanding Bell Inequality of Quantum Computing
Published: 2022-03-27 16:27:26

Quantum Mechanics/Physics is rising and intersting field, right?. When learning it you come across topic called Bell Inequality. This is little guide for it.

It is a test which depends on Quantum Mechanics to describe real world experiment.

So let's know what is it and how do we calculate it.

### Bell Inequality

John Stewart Bell is a Irish physicist. He devised an amazing test which distinguish between Bohr and Einstein models. Most amazing feature of this test is not only it is philosophies but also testable. So, let's take a look at it.

Before we start learning Bell Inequality, we have to learn it's basic ideas on which it depends. I hope you have basic knowledge about matrices and it's operations.

### Basic

Column vector represent as "ket"  {% katex inline %} \ket{\psi} {% endkatex %}


![Column vector represent as ket](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kz7w7dyof3ftltqp9wt4.jpg)

Row vector represent as "bra" 
{% katex inline %} \bra{\psi} {% endkatex %}

![Row vector represent as bra](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fp3afer1u3bxo801q8zo.jpg)

You can look at it like this
![bra-ket ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mks1mm0n9wzdqsb2tvhq.jpg)

### Hadamard gate

Also known as H gate. It is single qubit operation that map qubit into equal superposition.

Simply it convert basis state into equally superposition states like this 

{% katex %}
\ket{0} = {\ket{0} + \ket{1} \above{2pt}
 \sqrt{2}}
{% endkatex %}

{% katex %}
\ket{1} = {\ket{0} - \ket{1} \above{2pt} \sqrt{2}}
{% endkatex %}

Matrix for this is

![Hadamard matrix of 2x2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hbdv8nt45jvcz11snxl.jpg)

Simply every element is 1 with scalar multiple of {% katex inline %} {1 \above{1pt} \sqrt{2}} {% endkatex %}

example let's calculate hadamard matrix for {% katex inline %} \ket{0} {% endkatex %} 

![calculating hadamard matrix for qubit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esxy38wsu8g6tbo68d27.jpg)

At top we write matrix for {% katex inline %} \ket{0} {% endkatex %} , take look at it because it contains 1 at top and 0 and bottom describing it is at {% katex inline %} \ket{0} {% endkatex %} state. Side of it is Hadamard matrix (H). Below is simply multiplication of 2x2 matrix and 2x1 matrix. After calculating we get 2x1 matrix containing 1 at each position indicating it has both {% katex inline %} \ket{0} \ket{1} {% endkatex %} states 
and at the end we can write it in simple form 
{% katex %}
\ket{0} = {\ket{0} + \ket{1} \above{2pt} \sqrt{2}}
{% endkatex %}

#### <u>Symbol</u>
![Hadamard gate symbol](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f12scm0pt6rkuxnqvd0n.jpg)

### CNOT Gate

It is two qubit operation. So it take two qubit as input, label it as first is "control" qubit and second is "target" qubit. Main point to remember is, 
- If control qubit is 1 then it perform Pauli-X gate on target qubit means convert 0 to 1 or vice-versa. 
- If control qubit is 0, then target qubit remain unchanged.

You can consider this as classical NOT gate.
Example

{% katex  %}
\ket{00} = \ket{00}
{% endkatex %}

{% katex %}
\ket{01} = \ket{01}
{% endkatex %}

{% katex %}
\ket{10} = \ket{11}
{% endkatex %}

{% katex %}
\ket{11} = \ket{10}
{% endkatex %}

#### <u>Symbol</u>

![CNOT gate symbol](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/560jx2gy189843qy36aq.jpg)

That's it we need to understand Bell Inequality, although you read EPR and Bell's story as additional resources to your knowledge.

### Bell Inequality

Before getting output from Bell circuit (similar to classical logic circuit) it first undergo Hadamard transformation and then CNOT gate act on it and give us output.

#### <u>Process</u>

Now we have hadamard gates and CNOT gate with us the circuit of Bell state is 

![Bell circuit](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7u67j310uktllco9nw15.jpg)

So first hadamard gate act on it like
{% katex %}
\ket{0} = {\ket{0} + \ket{1} \above{2pt} \sqrt{2}}
{% endkatex %}

And after converting {% katex inline %} \ket{0} {% endkatex %} to it's equally superposition states we apply CNOT gate. As CNOT gate require two qubits as input.
{% katex %}
\ket{00} = {(\ket{0} + \ket{1})\ket{0} \above{2pt} \sqrt{2}}
{% endkatex %}

{% katex %} 
\ket{00} = {\ket{00} + \ket{10} \above{2pt} \sqrt{2}}
{% endkatex %}

We know CNOT gate will change target qubit if control qubit is 1 else it remains unchanged.

{% katex %}
\ket{00} = {\ket{00} + \ket{11} \above{2pt} \sqrt{2}}
{% endkatex %}

Similarly we get another 3 states.

for {% katex inline %} \ket{01} {% endkatex %}
{% katex %}
\ket{01} = {\ket{01} + \ket{10} \above{2pt} \sqrt{2}}
{% endkatex %}

for {% katex inline %} \ket{10} {% endkatex %}
{% katex %}
\ket{10} = {\ket{00} - \ket{11} \above{2pt} \sqrt{2}}
{% endkatex %}

for {% katex inline %} \ket{11} {% endkatex %}
{% katex %}
\ket{11} = {\ket{01} - \ket{10} \above{2pt} \sqrt{2}}
{% endkatex %}

And above are Bell's states/pairs