Quick Example
Fixed-Angle Ansatz: Quantum Circuit Example
Prepare a two-qubit ansatz at fixed angles
What this example teaches
Prepare a two-qubit ansatz at fixed angles.
Expected result
In browser wire order, ideal probabilities are 00: 37.3410%, 01: 27.2026%, 10: 14.0769%, and 11: 21.3795%. This fixed-angle circuit does not calculate an energy or optimize parameters.
Browser bit strings list physical wires q0 first, including auxiliary wires. Native classical-register strings can use another order; inspect the declared measurements.
These are ideal probabilities. Sampled frequencies fluctuate when more than one outcome is possible; they need not match percentages exactly. An ideal outcome with probability 100% has no finite-shot variation. Hardware noise is a separate effect.
Try the example
The link opens the editor. Save existing work, then choose Examples → Fixed-Angle Ansatz → framework. Click Run, choose an available browser simulator, then click Run in browser. The link does not preselect or execute the example.
Scope and limitations
- There is no Hamiltonian, molecular mapping, energy calculation or optimizer; no H2 energy is claimed.
These expected answers describe the fixed circuit. This page does not establish a completed hosted or hardware run. Read the user guide for this example.
Inspect and download the circuit
Inspect the same fixed circuit in five frameworks. Browser execution translates supported circuit definitions into OpenQASM; it does not run general Python. Outside Marqov, Qiskit, Cirq, and Marqov snippets need a separate simulator invocation. PennyLane invokes its QNode and stores sampled counts in result.
OpenQASM
// Fixed-Angle Ansatz — state preparation only; no Hamiltonian or optimization
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
// Fixed-angle state preparation; no energy calculation
ry(0.5) q[0];
ry(1.2) q[1];
cx q[0],q[1];
ry(0.8) q[0];
ry(0.3) q[1];
measure q -> c;
Download OpenQASM circuitQiskit
# Fixed-Angle Ansatz — state preparation only; no Hamiltonian or optimization
from qiskit import QuantumCircuit
import math
qc = QuantumCircuit(2, 2)
# Fixed-angle state preparation; no energy calculation
qc.ry(0.5, 0)
qc.ry(1.2, 1)
qc.cx(0, 1)
qc.ry(0.8, 0)
qc.ry(0.3, 1)
qc.measure([0, 1], [0, 1])
Download Qiskit circuitCirq
# Fixed-Angle Ansatz — state preparation only; no Hamiltonian or optimization
import cirq
import numpy as np
q0, q1 = cirq.LineQubit.range(2)
circuit = cirq.Circuit([
# Fixed-angle state preparation; no energy calculation
cirq.ry(0.5)(q0),
cirq.ry(1.2)(q1),
cirq.CNOT(q0, q1),
cirq.ry(0.8)(q0),
cirq.ry(0.3)(q1),
cirq.measure(q0, q1, key="result"),
])
Download Cirq circuitPennyLane
# Fixed-Angle Ansatz — state preparation only; no Hamiltonian or optimization
import pennylane as qml
import numpy as np
dev = qml.device("default.qubit", wires=2, shots=1000)
@qml.qnode(dev)
def vqe_ansatz():
# Fixed-angle state preparation; no energy calculation
qml.RY(0.5, wires=0)
qml.RY(1.2, wires=1)
qml.CNOT(wires=[0, 1])
qml.RY(0.8, wires=0)
qml.RY(0.3, wires=1)
return qml.counts()
result = vqe_ansatz()
Download PennyLane circuitMarqov
# Fixed-Angle Ansatz — state preparation only; no Hamiltonian or optimization
from marqov import Circuit
circuit = (
Circuit()
.ry(0.5, 0).ry(1.2, 1)
.cnot(0, 1)
.ry(0.8, 0).ry(0.3, 1)
)
Download Marqov circuitSources and provenance
These references explain the concept and gate conventions. The snippets originate in Marqov's internal example collection; an upstream code attribution has not been established.
Snapshot identity
- Source revision
df5a80cd474144684bf69dbda237b28ce40cc48c- Example version
a8228a82c4e5832da5c6b892c26dd5217befeaa1bf01d1f2527ad18711dec23a
The source revision identifies the editor collection used for this snapshot. The example version identifies its five exact code variants; neither is evidence of a hosted run.
Go deeper
For a paper-based experiment with scientific comparisons and execution evidence, read Research Replications. Its published scope and availability are separate from this small teaching circuit.