lundi 7 novembre 2022

(quantum computing) Examples of code for a "Bell state" : IBM quantum composer vs. OpenQASM vs. Qiskit

 

    • https://quantum-computing.ibm.com/composer/files/new "Quantum Composer" IDE to build Q-progs : "Composer has a customizable set of tools that allow you to build, visualize, and run quantum circuits on quantum hardware or simulators".
    • graphical editor for openQASM  or Qiskit formalisms


Examples of code generated in the step by step tutorial to create a "Bell state"

https://quantum-computing.ibm.com/composer/docs/iqx/example-circuits/bell

Same code, but different languages; done on the Quantum Composer ide following the initial step by step guide.


The Bell test demonstrates that measurements of an entangled state cannot be explained by any local hidden variable theory, and that there must be correlations that are beyond classical.

from: https://quantum-computing.ibm.com/composer/docs/iqx/example-circuits/bell



* Quantum Composer





* OpenQASM

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

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from numpy import pi

qreg_q = QuantumRegister(2, 'q')
creg_c = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)

circuit.h(qreg_q[0])
circuit.cx(qreg_q[0], qreg_q[1])
circuit.measure(qreg_q[0], creg_c[0])
circuit.measure(qreg_q[1], creg_c[1])

Aucun commentaire:

Enregistrer un commentaire