All examples
Quantum computing

Create an experimental Bell pair

Build an immutable two qubit circuit, inspect exact ideal probabilities and compare seeded CPU measurement counts.

Experimental module
quantum_bell.aner
// Experimental aner.quantum; requires the updated native development runtime.
import aner.quantum

let backend = quantum.cpu()
let bell = quantum.circuit(qubits: 2).h(0).cx(0, 1)
let result = bell.run(backend: backend, shots: 4096, seed: 2026)

print(backend.summary())
print(bell.summary())
print(result.summary())
print(result.counts())
print("Only 00 and 11 are observed")
print(result.count("00") + result.count("11") == result.shots())
print("Ideal simulator probability of 00 is one half")
print(result.probability("00"))
print("Sampled Z on qubit zero approaches zero")
print(result.sampled_z(0))

Make it your experiment.

With a compatible development runtime installed, save this program as examples/quantum_bell.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/quantum_bell.aner
aner run examples/quantum_bell.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use the updated native Aner development runtime with the experimental aner.quantum CPU simulator. Earlier packaged executables may not recognize this module. The complete examples run locally with no external service, credential or quantum hardware. Reserved GPU, cluster and physical hardware descriptors report unavailable; requested execution fails explicitly without fallback.

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner