The files in this directory (cirq/examples/
) are examples of various quantum
programs, algorithms, and demonstrations of using Cirq. This directory is not
included in the packaged Cirq releases.
Here is a summary of the examples found in this directory:
basic_arithmetic.py
: examples of various basic arithmetic circuits.bb84.py
: demonstration of the BB84 QKD Protocol.bcs_mean_field.py
: example of a quantum circuit to prepare the BCS ground states for superconductors/superfluids.bell_inequality.py
: demonstration of Bell's theorem.bernstein_vazirani.py
: demonstration of the Bernstein-Vazirani algorithm.deutsch.py
: demonstration of Deutsch's algorithm.direct_fidelity_estimation.ipynb
: an example that walks through the steps of running the direct fidelity estimation (DFE) algorithmgrover.py
: demonstration of Grover's algorithm.heatmaps.py
: demonstration of howcirq.Heatmap
can be used to generate a heatmap of qubit fidelities.hello_qubit.py
: example of a simple quantum circuit.hhl.py
: demonstration of the algorithm for solving linear systems by Harrow, Hassidim, and Lloyd.hidden_shift_algorithm.py
: demonstration of a Hidden Shift algorithm.noisy_simulation_example.py
: example of a noisy circuit using thecirq.ConstantQubitNoiseModel
class.phase_estimator.py
: example of a phase estimator circuit.qaoa.py
: example of the Quantum Approximate Optimization Algorithm applied to the Max-Cut problem.quantum_fourier_transform.py
: example of a circuit for Quantum Fourier Transform (QFT) on 4 qubits.quantum_teleportation.py
: demonstration of a (simulation of) quantum teleportation.qubit_characterizations_example.py
: examples of how to run various qubit characterizations.shor.py
: demonstration of Shor's algorithm.shors_code.py
: demonstration of Shor's code, a stabilizer code for quantum error correction.simon_algorithm.py
: demonstration of Simon's algorithm.stabilizer_code.ipynb
: example of quantum error correction using a stabilizer code.superdense_coding.py
: example of superdense coding.swap_networks.py
: demontration of swap networks.two_qubit_gate_compilation.py
: example application of the two-qubit gate compilation algorithm.
To learn more about the examples in this directory, look inside the Python
.py
files for a docstring comment
near the top of the file. (You can ignore the files whose names end in
_test.py
; those are unit tests
for the example files.)
The Experiments page on the Cirq documentation site has more examples, including examples drawn from the ReCirq project.