Build and Run Circuits
This guide provides recipes for the primary workflow in pyrauli
: building a
Circuit
object and using it to evolve an Observable
.
Construct a Basic Circuit
The Circuit
class is the main entry point. You initialize it with the
number of qubits and then add gates sequentially. Finally, you run the circuit on a target Observable.
# Create a 2-qubit circuit
qc = pyrauli.Circuit(2)
# Add gates
qc.add_operation("H", 0)
qc.add_operation("CX", 0, 1)
# Define an observable and run the circuit
observable = pyrauli.Observable("ZI")
final_observable = qc.run(observable)
print(f"Expectation value of ZI: {final_observable.expectation_value()}")
Note
Circuit
supports all Pauli gates (I, X, Y, Z), the Hadamard gate (H), the CNOT gate (CX) and the RZ(\(\theta\)) gate.
Tip
For more complex gates, you may use the Qiskit transpiler on Pbackend
. See Integrate with Qiskit.