Different quantum circuits are equivalent. For example the following pairs of quantum circuits have exacly the same effect on the quantum state.

Hadamard and two rotations:

q[0] |
---|

q[0] |
---|

Two successive Hadamard gates are equivalent to the identity operation.

q[0] |
---|

q[0] |
---|

The CNOT gate is equivalent to the CZ gate surrounded by two single qubit rotations (see Gate decompositions)

A quantum compiler can use this information to reduce the number of gates in a quantum circuit or replace gates that have a known bad fidelity with a series of gates that perform better on a given device.

## Optimizing with Project Q

With the ProjectQ backend of the SDK it is possible to optimize quantum circuits. See the documentation of ProjectQ on compiler engines for details.