# Textbook Examples¶

Cirq comes with a collection of example implementations of well-known quantum algorithms that demonstrate the main features of the library. Most of these can be found in the examples directory in the Github repository.

In addition to these examples, you can also find the notebooks that generated the cirq docs found here in the docs directory as well as all the more advanced tutorials listed further down on this page.

Below is a listing of the examples in the repository:

## Introductory algorithms¶

• Hello Qubit Simple first program showing how to create a quantum circuit.

• Deutsch Algorithm Textbook example of the simplest quantum advantage.

• Bernstein-Vazirani Textbook algorithm determining a global property of a function with surprisingly few calls to it.

• Bell Inequality Demonstration of a Bell inequality which shows impossibility of local hidden variable theories.

• BB84 Textbook algorithm for Quantum Key Distribution.

• Noisy simulation How to use a noisy simulator to generate results with amplitude damping.

• Line placement How to find a line of adjacent qubits on a device.

• Quantum Teleportation A demonstration of using 2 classical bits to transport a quantum state from one qubit to another.

• Super dense coding Transmit 2 classical bits using one quantum bit.

## Intermediate Textbook Algorithms¶

• Grover Algorithm Textbook algorithm for finding a single element hidden within a oracle function.

• Quantum Fourier Transform A demonstration of a 4-qubit quantum fourier transform (QFT).

• Basic Arithmetic Algorithms for adding and multiplying numbers as represented by quantum states.

• Phase estimation Textbook algorithm for phase estimation, i.e. for finding an eigenvalue of a unitary operator.

• Shor Quantum algorithm for integer factoring.

• QAOA Demonstration of the quantum approximation optimization algorithm (QAOA) on a max-cut problem.

## Intermediate NISQ techniques¶

• XEB Fidelity estimation using cross-entropy benchmarking (XEB).

• Direct fidelity Direct fidelity estimation to distinguish a desired state from the actual state using few Pauli measurements.

• Qubit Characterization Qubit characterizations using Rabi oscillations, randomized benchmarking, and tomography.

• Swap networks Algorithm for efficiently emulating full connectivity on a limited connectivity grid of qubits.

• HHL Algorithm for solving linear systems using quantum phase estimation.

• BCS Mean Field Quantum circuit to prepare the BCS ground states for superconductors/superfluids.