Bell circuit Updated +Created
A quantum circuit which when fed with input produces the Bell state.
Figure 1.
Quantum circuit that generates the Bell state
. Source.
The fundamental intuition for this circuit is as follows.
First the Hadamard gate makes the first qubit be in a 50/50 state.
Then, the CNOT gate gets controlled by that 50/50 value, and the controlled qubit also gets 50/50 chance as a result.
However, both qubits are now entangled: the result of the second qubit depends on the result of the first one. Because:
  • if the first qubit is 0, cnot is not active, and so the second qubit remains 0 as its input
  • if the first qubit is 1, cnot is active, and so the second qubit is flipped to 1
@cirosantilli/_file/qiskit/qiskit/hello.py Updated +Created
Our example uses a Bell state circuit to illustrate all the fundamental Qiskit basics.
Sample program output, counts are randomized each time.
First we take the quantum state vector immediately after the input.
input:
state:
Statevector([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
            dims=(2, 2))
probs:
[1. 0. 0. 0.]
We understand that the first element of Statevector is , and has probability of 1.0.
Next we take the state after a Hadamard gate on the first qubit:
h:
state:
Statevector([0.70710678+0.j, 0.70710678+0.j, 0.        +0.j,
             0.        +0.j],
            dims=(2, 2))
probs:
[0.5 0.5 0.  0. ]
We now understand that the second element of the Statevector is , and now we have a 50/50 propabability split for the first bit.
Then we apply the CNOT gate:
cx:
state:
Statevector([0.70710678+0.j, 0.        +0.j, 0.        +0.j,
             0.70710678+0.j],
            dims=(2, 2))
probs:
[0.5 0.  0.  0.5]
which leaves us with the final .
Then we print the circuit a bit:
qc without measure:
     ┌───┐
q_0: ┤ H ├──■──
     └───┘┌─┴─┐
q_1: ─────┤ X ├
          └───┘
c: 2/══════════

qc with measure:
     ┌───┐     ┌─┐
q_0: ┤ H ├──■──┤M├───
     └───┘┌─┴─┐└╥┘┌─┐
q_1: ─────┤ X ├─╫─┤M├
          └───┘ ║ └╥┘
c: 2/═══════════╩══╩═
                0  1
qasm:
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0],q[1];
measure q[0] -> c[0];
measure q[1] -> c[1];
And finally we compile the circuit and do some sample measurements:
qct:
     ┌───┐     ┌─┐
q_0: ┤ H ├──■──┤M├───
     └───┘┌─┴─┐└╥┘┌─┐
q_1: ─────┤ X ├─╫─┤M├
          └───┘ ║ └╥┘
c: 2/═══════════╩══╩═
                0  1
counts={'11': 484, '00': 516}
counts={'11': 493, '00': 507}
Microsoft Updated +Created
And also their monopolistic practices: United States v. Microsoft Corp.
So, as put in Video "Bill Gates vs Steve Jobs by Epic Rap Battles of History (2012)" by fake Steve Jobs to fake Bill Gates:
Why'd you name your company after your dick?
However, like all big tech companies with infinite money, they do end up doing some cool things in their research department, Microsoft Research, notably for Ciro Santilli being:
OpenQASM Updated +Created
On Qiskit qiskit==0.44.1:
qc.qasm()
E.g. with our qiskit/hello.py, we obtain the Bell state circuit:
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0],q[1];
measure q[0] -> c[0];
measure q[1] -> c[1];
qiskit/initialize.py Updated +Created
In this example we will initialize a quantum circuit with a single CNOT gate and see the output values.
By default, Qiskit initializes every qubit to 0 as shown in the qiskit/hello.py. But we can also initialize to arbitrary values as would be done when computing the output for various different inputs.
Output:
     ┌──────────────────────┐
q_0: ┤0                     ├──■──
     │  Initialize(1,0,0,0) │┌─┴─┐
q_1: ┤1                     ├┤ X ├
     └──────────────────────┘└───┘
c: 2/═════════════════════════════

init: [1, 0, 0, 0]
probs: [1. 0. 0. 0.]

init: [0, 1, 0, 0]
probs: [0. 0. 0. 1.]

init: [0, 0, 1, 0]
probs: [0. 0. 1. 0.]

init: [0, 0, 0, 1]
probs: [0. 1. 0. 0.]

     ┌──────────────────────────────────┐
q_0: ┤0                                 ├──■──
     │  Initialize(0.70711,0,0,0.70711) │┌─┴─┐
q_1: ┤1                                 ├┤ X ├
     └──────────────────────────────────┘└───┘
c: 2/═════════════════════════════════════════

init: [0.7071067811865475, 0, 0, 0.7071067811865475]
probs: [0.5 0.5 0.  0. ]
which we should all be able to understand intuitively given our understanding of the CNOT gate and quantum state vectors.
quantumcomputing.stackexchange.com/questions/13202/qiskit-initializing-n-qubits-with-binary-values-0s-and-1s describes how to initialize circuits qubits only with binary 0 or 1 to avoid dealing with the exponential number of elements of the quantum state vector.
Quantum circuits vs classical circuits Updated +Created
Just like a classic programmer does not need to understand the intricacies of how transistors are implemented and CMOS semiconductors, the quantum programmer does not understand physical intricacies of the underlying physical implementation.
The main difference to keep in mind is that quantum computers cannot save and observe intermediate quantum state, so programming a quantum computer is basically like programming a combinatorial-like circuit with gates that operate on (qu)bits:
For this reason programming a quantum computer is much like programming a classical combinatorial circuit as you would do with SPICE, verilog-or-vhdl, in which you are basically describing a graph of gates that goes from the input to the output
For this reason, we can use the words "program" and "circuit" interchangeably to refer to a quantum program
Also remember that and there is no no clocks in combinatorial circuits because there are no registers to drive; and so there is no analogue of clock in the quantum system either,
Another consequence of this is that programming quantum computers does not look like programming the more "common" procedural programming languages such as C or Python, since those fundamentally rely on processor register / memory state all the time.
Quantum programmers can however use classic languages to help describe their quantum programs more easily, for example this is what happens in Qiskit, where you write a Python program that makes Qiskit library calls that describe the quantum program.
Quantum compilation Updated +Created
Software that maps higher level languages like Qiskit into actual quantum circuits.
Quantum Fourier transform Updated +Created
Sample implementations: